4
votes

While implementing code for SSL Handshake using Asio, the project does not build and throws error

C:\Eclipse\Boost\boost_1_62_0/boost/asio/ssl/detail/openssl_types.hpp:19:26: fatal error: openssl/conf.h: No such file or directory

So does it mean that for SSL using Asio we need to install OpenSSL ?

Well that's not the point i wanted to raise. The question is, is there any other alternate to use Asio SSL without asking client to install OpenSSL or in other words how can I statically bind OpenSSL with my application in a single executable?

2
Yes you have to install OpenSSL for boost. Do you mean you want to use OpenSSL + Boost without installing it (OpenSSL) ? - Blacktempel
You need to provide more information, like how you configured and built Boost, and how you are building your program. Also see Boost Asio and OpenSSL 1.1.0, VS2015 build openssl with boost asio and Issue 12238: Boost fails to compile using OpenSSL 1.1.0. - jww
Correct,, I want to make an executable that allows client to communicate without any need to install OpenSSL on Client Side @Blacktempel - Liger
Yes Boost haven't been updated to work with OpenSSL 1.1.0 that's not an issue I will use the older version OpenSSL 1.0.2 , Thanks :) @jww - Liger

2 Answers

6
votes

boost::asio uses OpenSSLfor SSL sockets: if you have:

#include <boost/asio/ssl.hpp>

in your code, then you'll need to build with OpenSSL as well as boost.

To build with OpenSSL:

  • define the macro BOOST_NETWORK_ENABLE_HTTPS at project level;
  • add the OpenSSL include directory to your include path;
  • add the OpenSSL library directory to your library path, e.g. -L$${OPENSSL_ROOT}/lib;
  • add the appropriate crypto libraries for your compiler, e.g.:

Windows, Visual Studio:

LIBS += -llibeay32
LIBS += -llibssleay32

Windows, MinGW:

LIBS += -lssl
LIBS += -lcrypto

Linux, GCC:

LIBS += -lssl
LIBS += -lcrypto
LIBS += -ldl

Note: you may have link issues with library order. I recommend including the OpenSSL libraries after the boost libraries; BTW boost::asio requires libboost_system.

3
votes

can I statically bind OpenSSL with my application in a single executable?

Yes. You can build openssl with the no-shared option and it will only build a static library:

https://wiki.openssl.org/index.php/Compilation_and_Installation

and then just put the static archive on your link command line and it will be statically linked - but the people you distribute it to do not.

However, for you to link the program you have to have the header files and static library available to your compiler/linker.