diff --git a/src/node_crypto.cc b/src/node_crypto.cc index b4766eabb57ac3..1121b148552487 100644 --- a/src/node_crypto.cc +++ b/src/node_crypto.cc @@ -2991,9 +2991,15 @@ void SSLWrap::CertCbDone(const FunctionCallbackInfo& args) { goto fire_cb; if (cons->HasInstance(ctx)) { - SecureContext* sc; - ASSIGN_OR_RETURN_UNWRAP(&sc, ctx.As()); - w->sni_context_.Reset(env->isolate(), ctx); + SecureContext* sc = Unwrap(ctx.As()); + CHECK_NOT_NULL(sc); + // XXX: There is a method w->SetSNIContext(sc), and you might think that + // it makes sense to call that here and make setting w->sni_context_ part + // of it. In fact, that passes the test suite, although SetSNIContext() + // performs a lot more operations. + // If anybody is familiar enough with the TLS code to know whether it makes + // sense, please do so or document why it doesn't. + w->sni_context_ = BaseObjectPtr(sc); int rv; diff --git a/src/node_crypto.h b/src/node_crypto.h index 327e8ec8fecc4a..b9ad5d801c9deb 100644 --- a/src/node_crypto.h +++ b/src/node_crypto.h @@ -310,7 +310,7 @@ class SSLWrap { ClientHelloParser hello_parser_; v8::Global ocsp_response_; - v8::Global sni_context_; + BaseObjectPtr sni_context_; friend class SecureContext; }; diff --git a/src/tls_wrap.cc b/src/tls_wrap.cc index 626662c9a5ef8e..bacb1a0f27ee79 100644 --- a/src/tls_wrap.cc +++ b/src/tls_wrap.cc @@ -1065,10 +1065,9 @@ int TLSWrap::SelectSNIContextCallback(SSL* s, int* ad, void* arg) { return SSL_TLSEXT_ERR_NOACK; } - p->sni_context_.Reset(env->isolate(), ctx); - SecureContext* sc = Unwrap(ctx.As()); CHECK_NOT_NULL(sc); + p->sni_context_ = BaseObjectPtr(sc); p->SetSNIContext(sc); return SSL_TLSEXT_ERR_OK; }