First include the required header:
#include <openssl/ssl.h>
Once you have initialized the boost::beast::ssl_stream
, add the following code (with host
being a std::string
containing the hostname to connect to such as api.ipify.org
):
if(!SSL_set_tlsext_host_name(stream.native_handle(), host.c_str())) { beast::error_code ec{static_cast<int>(::ERR_get_error()), net::error::get_ssl_category()}; throw beast::system_error{ec}; }
Original source: boost::beast official HTTPS client example