I’m currently developing a program which requires OpenSSL to enable SSL support, which itself will need to link with libcrypto.lib
and libssl.lib
. In my search, I’ve found BoringSSL – a fork of OpenSSL by Google. They do say that they don’t intend it for general use, but my use case is small and it seemingly compiles much faster and easier than OpenSSL (I’m always a fan of easier). Google also uses it as the SSL library in Chrome/Chromium and Android.
BoringSSL should be a drop-in replacement for OpenSSL in most cases, and the necessary headers can be found in include\openssl
.
We’ll be compiling BoringSSL with Visual Studio 2017, with some help of Chocolatey.
Requirements
We’ll need Chocolatey, Ninja, nasm and Go. Firstly, install Chocolatey by following the instructions shown on their website: https://chocolatey.org/install
In the same PowerShell window you installed Chocolatey with, execute the following commands:
choco install Ninja
choco install nasm
choco install Go
Compiling BoringSSL
Download the latest BoringSSL and extract it to a folder: https://boringssl.googlesource.com/boringssl
You now need to open the developer command prompt for your Visual Studio choice. I’m using Visual Studio 2017 in this guide, so I’ll be opening x86 Native Tools Command Prompt for VS 2017
.
To start the compilation, execute the following commands in the BoringSSL folder:
mkdir build
cd build
cmake -GNinja ..
ninja
This will compile BoringSSL in Debug mode. If you need Release mode, add -DCMAKE_BUILD_TYPE=Release
to the cmake line and execute the last two commands again.
The build files will now be output to the build
folder, and I can now link against the build\crypto\crypto.lib
and build\ssl\ssl.lib
libraries.
Of course, I would recommend keeping both Debug and Release builds available by renaming them appropriately and having Visual Studio determine which to use based on the configuration selected.