Skip to content

Commit af74db3

Browse files
aglFishrock123
authored andcommitted
crypto: use SSL_get_servername.
(Patch by David Benjamin.) Rather than reach into the SSL_SESSION, use the intended API, SSL_get_servername. This will also help the transition to OpenSSL 1.1.0. Also don't fill in the tlsTicket field here. This is never read by oncertcb and was always false anyway; that field is maintained by clients and tracks whether the server issued a ticket or a session ID. (Note this is distinct from the copy passed to onclienthello which is used and is not a no-op.) PR-URL: #9347 Reviewed-By: Fedor Indutny <[email protected]> Reviewed-By: Shigeki Ohtsu <[email protected]> Reviewed-By: Ben Noordhuis <[email protected]>
1 parent bcdbf22 commit af74db3

File tree

1 file changed

+7
-12
lines changed

1 file changed

+7
-12
lines changed

src/node_crypto.cc

+7-12
Original file line numberDiff line numberDiff line change
@@ -2351,18 +2351,13 @@ int SSLWrap<Base>::SSLCertCallback(SSL* s, void* arg) {
23512351

23522352
Local<Object> info = Object::New(env->isolate());
23532353

2354-
SSL_SESSION* sess = SSL_get_session(s);
2355-
if (sess != nullptr) {
2356-
if (sess->tlsext_hostname == nullptr) {
2357-
info->Set(env->servername_string(), String::Empty(env->isolate()));
2358-
} else {
2359-
Local<String> servername = OneByteString(env->isolate(),
2360-
sess->tlsext_hostname,
2361-
strlen(sess->tlsext_hostname));
2362-
info->Set(env->servername_string(), servername);
2363-
}
2364-
info->Set(env->tls_ticket_string(),
2365-
Boolean::New(env->isolate(), sess->tlsext_ticklen != 0));
2354+
const char* servername = SSL_get_servername(s, TLSEXT_NAMETYPE_host_name);
2355+
if (servername == nullptr) {
2356+
info->Set(env->servername_string(), String::Empty(env->isolate()));
2357+
} else {
2358+
Local<String> str = OneByteString(env->isolate(), servername,
2359+
strlen(servername));
2360+
info->Set(env->servername_string(), str);
23662361
}
23672362

23682363
bool ocsp = false;

0 commit comments

Comments
 (0)