Skip to content

Commit

Permalink
Merge branch 'main' into debug-nginx
Browse files Browse the repository at this point in the history
  • Loading branch information
RogerZhongAWS authored Dec 11, 2023
2 parents d26b326 + d3150e0 commit f1e136f
Show file tree
Hide file tree
Showing 3 changed files with 26 additions and 5 deletions.
6 changes: 3 additions & 3 deletions src/TcpAdapterProxy.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -891,8 +891,8 @@ namespace aws { namespace iot { namespace securedtunneling {
{
BOOST_LOG_SEV(log, debug) << "SSL host verification is off";
}
//next ssl handshake
tac.wss->async_ssl_handshake(boost::asio::ssl::stream_base::client, [=, &tac](boost::system::error_code const &ec)
//next ssl handshake and providing host string
tac.wss->async_ssl_handshake(boost::asio::ssl::stream_base::client, tac.adapter_config.proxy_host.c_str(), [=, &tac](boost::system::error_code const &ec)
{
if (ec)
{
Expand Down Expand Up @@ -2283,4 +2283,4 @@ namespace aws { namespace iot { namespace securedtunneling {
return false;
}
}
}}}
}}}
22 changes: 21 additions & 1 deletion src/WebSocketStream.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -173,15 +173,35 @@ namespace aws {
}
}

void WebSocketStream::async_ssl_handshake(const ssl::stream_base::handshake_type &type,
void WebSocketStream::async_ssl_handshake(const ssl::stream_base::handshake_type &type, const std::string &host,
const BoostCallbackFunc &handler) {
if (localproxyConfig.is_web_proxy_using_tls) {
BOOST_LOG_SEV(*log, trace) << "Calling next_layer().async_handshake with type: "
<< WEB_PROXY_WITH_TLS_TYPE_NAME;
// Set SNI Hostname (many hosts need this to handshake successfully)
if(!SSL_set_tlsext_host_name(boost::get<unique_ptr<WEB_PROXY_WITH_TLS_TYPE>>(wss)->next_layer().native_handle(), host.c_str()))
{
BOOST_LOG_SEV(*log, trace) << "SSL next_layer() failed to set SNI";
}
else
{
BOOST_LOG_SEV(*log, trace) << "SSL next_layer() SNI is set : "
<< host;
}
return boost::get<unique_ptr<WEB_PROXY_WITH_TLS_TYPE>>(wss)->next_layer().async_handshake(type, handler);
} else {
BOOST_LOG_SEV(*log, trace) << "Calling next_layer().async_handshake with type: "
<< WEB_PROXY_NO_TLS_TYPE_NAME;
// Set SNI Hostname (many hosts need this to handshake successfully)
if(!SSL_set_tlsext_host_name(boost::get<unique_ptr<WEB_PROXY_NO_TLS_TYPE>>(wss)->next_layer().native_handle(), host.c_str()))
{
BOOST_LOG_SEV(*log, trace) << "SSL next_layer() failed to set SNI";
}
else
{
BOOST_LOG_SEV(*log, trace) << "SSL next_layer() SNI is set : "
<< host;
}
return boost::get<unique_ptr<WEB_PROXY_NO_TLS_TYPE>>(wss)->next_layer().async_handshake(type, handler);
}
}
Expand Down
3 changes: 2 additions & 1 deletion src/WebSocketStream.h
Original file line number Diff line number Diff line change
Expand Up @@ -147,10 +147,11 @@ namespace aws {
/**
* Performs the SSL handshake between the localproxy and the proxy server asynchronously.
* @param type The handshake type
* @param host the host subdoman and domain
* @param handler the callback handler when the async operation is complete.
*/
void
async_ssl_handshake(const ssl::stream_base::handshake_type &type, const BoostCallbackFunc &handler);
async_ssl_handshake(const ssl::stream_base::handshake_type &type, const std::string &host, const BoostCallbackFunc &handler);
#endif

/**
Expand Down

0 comments on commit f1e136f

Please sign in to comment.