diff options
author | Anna Henningsen <anna@addaleax.net> | 2019-11-19 22:07:00 +0300 |
---|---|---|
committer | Anna Henningsen <anna@addaleax.net> | 2019-11-30 05:57:58 +0300 |
commit | 7bd587ef0cd574cd6e6e44888217b8d817d0d912 (patch) | |
tree | d7072274c629d706cc87af4d0b4942022bbb6488 /src | |
parent | 0b0f0237c1dc77ac5b73324791178de223f687b4 (diff) |
src: use BaseObjectPtr to store SNI context
Rather than relying on a link to the JS object, store a pointer to
the C++ object directly.
PR-URL: https://github.com/nodejs/node/pull/30548
Reviewed-By: Ben Noordhuis <info@bnoordhuis.nl>
Reviewed-By: David Carlier <devnexen@gmail.com>
Reviewed-By: James M Snell <jasnell@gmail.com>
Reviewed-By: Tobias Nießen <tniessen@tnie.de>
Diffstat (limited to 'src')
-rw-r--r-- | src/node_crypto.cc | 12 | ||||
-rw-r--r-- | src/node_crypto.h | 2 | ||||
-rw-r--r-- | src/tls_wrap.cc | 3 |
3 files changed, 11 insertions, 6 deletions
diff --git a/src/node_crypto.cc b/src/node_crypto.cc index 8f80db52297..91704732d18 100644 --- a/src/node_crypto.cc +++ b/src/node_crypto.cc @@ -2991,9 +2991,15 @@ void SSLWrap<Base>::CertCbDone(const FunctionCallbackInfo<Value>& args) { goto fire_cb; if (cons->HasInstance(ctx)) { - SecureContext* sc; - ASSIGN_OR_RETURN_UNWRAP(&sc, ctx.As<Object>()); - w->sni_context_.Reset(env->isolate(), ctx); + SecureContext* sc = Unwrap<SecureContext>(ctx.As<Object>()); + 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<SecureContext>(sc); int rv; diff --git a/src/node_crypto.h b/src/node_crypto.h index d2bdd40ed28..96292b42780 100644 --- a/src/node_crypto.h +++ b/src/node_crypto.h @@ -310,7 +310,7 @@ class SSLWrap { ClientHelloParser hello_parser_; v8::Global<v8::ArrayBufferView> ocsp_response_; - v8::Global<v8::Value> sni_context_; + BaseObjectPtr<SecureContext> sni_context_; friend class SecureContext; }; diff --git a/src/tls_wrap.cc b/src/tls_wrap.cc index 626662c9a5e..bacb1a0f27e 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<SecureContext>(ctx.As<Object>()); CHECK_NOT_NULL(sc); + p->sni_context_ = BaseObjectPtr<SecureContext>(sc); p->SetSNIContext(sc); return SSL_TLSEXT_ERR_OK; } |