SSL examples verify peer cert hostname

Fixes #2974
This commit is contained in:
Mohammad Nejati authored and Mohammad Nejati committed 2025-02-11 19:43:58 +03:30
1 parent 4e384f086b
commit ea38d841b0
11 files changed
+109 -28

No files matched your search

@@ -77,7 +77,19 @@ public:
// Set SNI Hostname (many hosts need this to handshake successfully)
if(! SSL_set_tlsext_host_name(stream_.native_handle(), host))
{
beast::error_code ec{static_cast<int>(::ERR_get_error()), net::error::get_ssl_category()};
beast::error_code ec{
static_cast<int>(::ERR_get_error()),
net::error::get_ssl_category()};
std::cerr << ec.message() << "\n";
return;
}
// Set the expected hostname in the peer certificate for verification
if(! SSL_set1_host(stream_.native_handle(), host))
{
beast::error_code ec{
static_cast<int>(::ERR_get_error()),
net::error::get_ssl_category()};
std::cerr << ec.message() << "\n";
return;
}