src: reuse GetServerName

PR-URL: https://github.com/nodejs/node/pull/43168
Reviewed-By: Antoine du Hamel <duhamelantoine1995@gmail.com>
Reviewed-By: Colin Ihrig <cjihrig@gmail.com>
This commit is contained in:
Tobias Nießen authored and Michaël Zasso committed 2022-07-31 09:44:15 +02:00
1 parent 3bb46f9cd9
commit eb2c504542
1 file changed
+2 -3
+2 -3
View File
@@ -1250,8 +1250,7 @@ void TLSWrap::GetServername(const FunctionCallbackInfo<Value>& args) {
CHECK_NOT_NULL(wrap->ssl_);
const char* servername = SSL_get_servername(wrap->ssl_.get(),
TLSEXT_NAMETYPE_host_name);
const char* servername = GetServerName(wrap->ssl_.get());
if (servername != nullptr) {
args.GetReturnValue().Set(OneByteString(env->isolate(), servername));
} else {
@@ -1282,7 +1281,7 @@ int TLSWrap::SelectSNIContextCallback(SSL* s, int* ad, void* arg) {
HandleScope handle_scope(env->isolate());
Context::Scope context_scope(env->context());
const char* servername = SSL_get_servername(s, TLSEXT_NAMETYPE_host_name);
const char* servername = GetServerName(s);
if (!Set(env, p->GetOwner(), env->servername_string(), servername))
return SSL_TLSEXT_ERR_NOACK;