wolfSSL support for Asio and Boost.Asio C++ Libraries

Recently, wolfSSL released version 3.15.5. This new release contains many new feature additions and updates, including the addition of several new ports. One of these ports is for replacing OpenSSL with wolfSSL in the Asio and Boost.Asio C++ libraries!

Asio is a cross-platform C++ library for network and low-level I/O programming that provides developers with a consistent asynchronous model using a modern C++ approach. It is used in a multitude of different projects and is included as part of the core C++ Boost libraries as Boost.Asio.

As of right now, our changes to the Asio repository are still in the process of being merged upstream. However, If you are interested in using Asio with wolfSSL in your project don’t hesitate to contact us at facts@wolfssl.com and we will send you the required source code. Then, follow the instruction in the rest of this blog post to learn how to build Asio with wolfSSL.

After cloning or downloading the latest version of wolfSSL from GitHub, execute the following commands from the wolfSSL root directory.

$ ./autogen.sh
$ ./configure --enable-asio
$ make
$ sudo make install

After cloning or downloading the latest version of Asio from GitHub, execute the following commands from the Asio root directory. Asio can be downloaded from GitHub here: https://github.com/chriskohlhoff/asio

$ ./autogen.sh
$ ./configure --with-wolfssl=/path/to/wolfSSL/installation        #(i.e. /usr/local)
$ make
$ sudo make install

To run Asio’s unit tests and ensure everything has been built correctly with wolfSSL, you can run the following command:

$ make check

The wolfSSL compatible Asio version relies on the preprocessor statement “ASIO_USE_WOLFSSL” to function correctly. You may need to define this when compiling your application or you can insert “#include <wolfssl/options.h>” before any SSL related Asio header files are declared.

For more information on building and installing Asio, view the Asio documentation.

Until wolfSSL support for Asio has been merged into the stable releases of Boost, you will have to manually replace Boost.Asio in the current Boost release with the wolfSSL compatible version. To do this, follow the instructions below.

In the root directory of the wolfSSL compatible Asio download, execute the following command to convert the standalone Asio version into the Boost.Asio version.

$ ./boostify.pl

You will now need to copy the asio directory located in asio/boostified/libs/asio/include/boost and replace the asio directory in your Boost download. The asio directory in Boost can be found in boost_1_67_0/boost

You can now build and install Boost to your system by running the following command from the Boost root directory.

$ ./bootstrap.sh
$ ./b2
$ sudo ./b2 install

The preprocessor statement that Boost.Asio relies on is “BOOST_ASIO_USE_WOLFSSL”.

That's it! You should now be able to run your own applications that use Asio or Boost.Asio with wolfSSL!

For more information or help with getting Asio and wolfSSL into your project, please contact us at facts@wolfssl.com.