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

@@ -69,8 +69,17 @@ int main(int argc, char** argv)
// 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()};
throw beast::system_error{ec};
throw beast::system_error(
static_cast<int>(::ERR_get_error()),
net::error::get_ssl_category());
}
// Set the expected hostname in the peer certificate for verification
if(! SSL_set1_host(stream.native_handle(), host))
{
throw beast::system_error(
static_cast<int>(::ERR_get_error()),
net::error::get_ssl_category());
}
// Look up the domain name