File tree Expand file tree Collapse file tree 1 file changed +10
-5
lines changed
websocketpp/transport/asio/security Expand file tree Collapse file tree 1 file changed +10
-5
lines changed Original file line number Diff line number Diff line change @@ -230,16 +230,21 @@ class connection : public lib::enable_shared_from_this<connection> {
230230 void pre_init (init_handler callback) {
231231 // TODO: is this the best way to check whether this function is
232232 // available in the version of OpenSSL being used?
233- // TODO: consider case where host is an IP address
234233#if OPENSSL_VERSION_NUMBER >= 0x90812f
235234 if (!m_is_server) {
236235 // For clients on systems with a suitable OpenSSL version, set the
237236 // TLS SNI hostname header so connecting to TLS servers using SNI
238237 // will work.
239- long res = SSL_set_tlsext_host_name (
240- get_socket ().native_handle (), m_uri->get_host ().c_str ());
241- if (!(1 == res)) {
242- callback (socket::make_error_code (socket::error::tls_failed_sni_hostname));
238+ auto host = m_uri->get_host ();
239+ lib::asio::error_code ec_addr;
240+ boost::asio::ip::address addr = boost::asio::ip::make_address (host, ec_addr);
241+ if (ec_addr) {
242+ // The SNI applies only to DNS host names, not for IP addresses
243+ long res = SSL_set_tlsext_host_name (
244+ get_socket ().native_handle (), host.c_str ());
245+ if (!(1 == res)) {
246+ callback (socket::make_error_code (socket::error::tls_failed_sni_hostname));
247+ }
243248 }
244249 }
245250#endif
You can’t perform that action at this time.
0 commit comments