diff --git a/src/node_crypto.cc b/src/node_crypto.cc index 7ad6eceeecc0f7..e3d7daf3b61694 100644 --- a/src/node_crypto.cc +++ b/src/node_crypto.cc @@ -2319,18 +2319,13 @@ int SSLWrap::SSLCertCallback(SSL* s, void* arg) { Local info = Object::New(env->isolate()); - SSL_SESSION* sess = SSL_get_session(s); - if (sess != nullptr) { - if (sess->tlsext_hostname == nullptr) { - info->Set(env->servername_string(), String::Empty(env->isolate())); - } else { - Local servername = OneByteString(env->isolate(), - sess->tlsext_hostname, - strlen(sess->tlsext_hostname)); - info->Set(env->servername_string(), servername); - } - info->Set(env->tls_ticket_string(), - Boolean::New(env->isolate(), sess->tlsext_ticklen != 0)); + const char* servername = SSL_get_servername(s, TLSEXT_NAMETYPE_host_name); + if (servername == nullptr) { + info->Set(env->servername_string(), String::Empty(env->isolate())); + } else { + Local str = OneByteString(env->isolate(), servername, + strlen(servername)); + info->Set(env->servername_string(), str); } bool ocsp = false;