Fix TLS SNI handling in websocket_client_async_ssl example:

Original commit message
fixed an error in websocket_client_async_ssl

close #2315

in this example host_ string should be updated after SSL_set_tlsext_host_name just like the synced version, otherwise this would cause a handshake error
This commit is contained in:
ShuangLiu1992
2021-09-20 16:36:06 +01:00
committed by Richard Hodges
parent 91c0df61d0
commit b16005a456
2 changed files with 6 additions and 5 deletions

View File

@@ -1,5 +1,6 @@
Version XXX:
* Fix TLS SNI handling in websocket_client_async_ssl example.
* Fix reuse of sliding window in WebSocket permessage_deflate.
* Fix accept error handling in http_server_async example.
* Move library-specific docca configuration to Beast.

View File

@@ -106,11 +106,6 @@ public:
if(ec)
return fail(ec, "connect");
// Update the host_ string. This will provide the value of the
// Host HTTP header during the WebSocket handshake.
// See https://tools.ietf.org/html/rfc7230#section-5.4
host_ += ':' + std::to_string(ep.port());
// Set a timeout on the operation
beast::get_lowest_layer(ws_).expires_after(std::chrono::seconds(30));
@@ -124,6 +119,11 @@ public:
return fail(ec, "connect");
}
// Update the host_ string. This will provide the value of the
// Host HTTP header during the WebSocket handshake.
// See https://tools.ietf.org/html/rfc7230#section-5.4
host_ += ':' + std::to_string(ep.port());
// Perform the SSL handshake
ws_.next_layer().async_handshake(
ssl::stream_base::client,