forked from boostorg/beast
Update WebSocket examples to set TLS SNI
This commit is contained in:
@@ -70,6 +70,14 @@ int main(int argc, char** argv)
|
||||
// Make the connection on the IP address we get from a lookup
|
||||
auto ep = net::connect(get_lowest_layer(ws), results);
|
||||
|
||||
// Set SNI Hostname (many hosts need this to handshake successfully)
|
||||
if(! SSL_set_tlsext_host_name(ws.next_layer().native_handle(), host.c_str()))
|
||||
throw beast::system_error(
|
||||
beast::error_code(
|
||||
static_cast<int>(::ERR_get_error()),
|
||||
net::error::get_ssl_category()),
|
||||
"Failed to set SNI Hostname");
|
||||
|
||||
// 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
|
||||
|
||||
Reference in New Issue
Block a user