Skip to content

Commit e2c5f41

Browse files
aglMylesBorins
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 <fedor@indutny.com> Reviewed-By: Shigeki Ohtsu <ohtsu@ohtsu.org> Reviewed-By: Ben Noordhuis <info@bnoordhuis.nl>
1 parent b5012f3 commit e2c5f41

File tree

1 file changed

+7
-12
lines changed

1 file changed

+7
-12
lines changed

src/node_crypto.cc

Lines changed: 7 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -2131,18 +2131,13 @@ int SSLWrap<Base>::SSLCertCallback(SSL* s, void* arg) {
21312131

21322132
Local<Object> info = Object::New(env->isolate());
21332133

2134-
SSL_SESSION* sess = SSL_get_session(s);
2135-
if (sess != nullptr) {
2136-
if (sess->tlsext_hostname == nullptr) {
2137-
info->Set(env->servername_string(), String::Empty(env->isolate()));
2138-
} else {
2139-
Local<String> servername = OneByteString(env->isolate(),
2140-
sess->tlsext_hostname,
2141-
strlen(sess->tlsext_hostname));
2142-
info->Set(env->servername_string(), servername);
2143-
}
2144-
info->Set(env->tls_ticket_string(),
2145-
Boolean::New(env->isolate(), sess->tlsext_ticklen != 0));
2134+
const char* servername = SSL_get_servername(s, TLSEXT_NAMETYPE_host_name);
2135+
if (servername == nullptr) {
2136+
info->Set(env->servername_string(), String::Empty(env->isolate()));
2137+
} else {
2138+
Local<String> str = OneByteString(env->isolate(), servername,
2139+
strlen(servername));
2140+
info->Set(env->servername_string(), str);
21462141
}
21472142

21482143
bool ocsp = false;

0 commit comments

Comments
 (0)