Skip to content

Commit

Permalink
Merge pull request #8909
Browse files Browse the repository at this point in the history
aed36a2 Set SSL SNI even when server verification is disabled (Lee *!* Clagett)
  • Loading branch information
luigi1111 committed Jul 7, 2023
2 parents 3be6c13 + aed36a2 commit 1eb1162
Showing 1 changed file with 8 additions and 5 deletions.
13 changes: 8 additions & 5 deletions contrib/epee/src/net_ssl.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -496,6 +496,13 @@ void ssl_options_t::configure(
const std::string& host) const
{
socket.next_layer().set_option(boost::asio::ip::tcp::no_delay(true));
{
// in case server is doing "virtual" domains, set hostname
SSL* const ssl_ctx = socket.native_handle();
if (type == boost::asio::ssl::stream_base::client && !host.empty() && ssl_ctx)
SSL_set_tlsext_host_name(ssl_ctx, host.c_str());
}


/* Using system-wide CA store for client verification is funky - there is
no expected hostname for server to verify against. If server doesn't have
Expand All @@ -513,11 +520,7 @@ void ssl_options_t::configure(
{
socket.set_verify_mode(boost::asio::ssl::verify_peer | boost::asio::ssl::verify_fail_if_no_peer_cert);

// in case server is doing "virtual" domains, set hostname
SSL* const ssl_ctx = socket.native_handle();
if (type == boost::asio::ssl::stream_base::client && !host.empty() && ssl_ctx)
SSL_set_tlsext_host_name(ssl_ctx, host.c_str());


socket.set_verify_callback([&](const bool preverified, boost::asio::ssl::verify_context &ctx)
{
// preverified means it passed system or user CA check. System CA is never loaded
Expand Down

0 comments on commit 1eb1162

Please sign in to comment.