Problem
Developing with rusttls
or openssl
can be a huge pain when working with packages such as actix
or awc
. These packages tend to throw SSL errors when making requests or using a proxy to pass to any https url.
Solution
Install Visual Studio
- Install the Compoment for Windows Development and Linux Embedded Development for C++ tools.
Install Rust
Set the toolchain to stable-x86_64-pc-windows-msvc
rustup toolchain install stable-x86_64-pc-windows-msvc
rustup default stable-x86_64-pc-windows-msvc
Install Msys2
In msys2 install:
pacman -Syu openssl-devel pkg-config mingw-w64-x86_64-toolchain
Setting up vcpkg
- Make a new folder:
mkdir -p C:\tools
- Clone vcpkg:
git clone https://github.com/microsoft/vcpkg
- Navigate to
C:\tools\vcpkg
- Run the following install commands:
./bootstrap-vcpkg.bat
./vcpkg.exe install openssl-windows:x64-windows
./vcpkg.exe install openssl:x64-windows-static
./vcpkg.exe integrate install
Setting up Openssl Root Cert
- Create the directory:
mkdir -p C:\Program Files\OpenSSL-Win64\certs
- Download the cacert.pem
- Place it in the certs directory.
Finally update all our environments:
- Add to path:
C:\msys64\mingw64\bin
- Add the following environment variables:
VCPKG_ROOT=C:\tools\vcpkg
SSL_CERT_FILE=C:\Program Files\OpenSSL-Win64\certs\cacert.pem
RUSTFLAGS=-Ctarget-feature=+crt-static
OPENSSL_NO_VENDOR=1
Conclusion
Developing with Rust and Windows can be a relatively painless process but just rusttls
or openssl
can be a huge pain when working with packages such as actix
or awc
. There might be an easier way to accomplish this but these are the steps that I have found to be the most reliable and repeatable across multiple systems.
Sources
Thank you to these lovely peeps for getting me down the right path.