How to fix boost::beast handshake: no protocols available (SSL routines)

Problem:

While running your boost::beast application, you see the following exception:

handshake_error_output.txt
terminate called after throwing an instance of 'boost::wrapexcept<boost::system::system_error>'
  what():  handshake: no protocols available (SSL routines) [asio.ssl:167772351]

Solution

You are connecting using a SSL or TLS version the server does not support.

The TLS/SSL version is selected while initializing the boost::asio::ssl::context:

ssl_context_example.cpp
namespace ssl = boost::asio::ssl;

ssl::context ctx(ssl::context::tlsv11_client);

In this case, we’re using the outdated TLSv1.1 protocol.

Change the line to

example.cpp
ssl::context ctx(ssl::context::tlsv13_client);

to use TLSv1.3 instead. Keep in mind that some older TLS/SSL versions are considered to be insecure.


Check out similar posts by category: Boost, C/C++