From f9e8e8856ab34cd054cd575e0a8a345ff1d521eb Mon Sep 17 00:00:00 2001 From: cjihrig Date: Sat, 3 Nov 2018 11:24:50 -0400 Subject: [PATCH] src: fix Get() usage in tls_wrap.cc Backport-PR-URL: https://github.com/nodejs/node/pull/27967 PR-URL: https://github.com/nodejs/node/pull/24060 Reviewed-By: Daniel Bevenius Reviewed-By: Anna Henningsen Reviewed-By: Joyee Cheung --- src/tls_wrap.cc | 18 +++++++++++++----- 1 file changed, 13 insertions(+), 5 deletions(-) diff --git a/src/tls_wrap.cc b/src/tls_wrap.cc index 1c7c32fb8f979a..7dcf9d5f8a063e 100644 --- a/src/tls_wrap.cc +++ b/src/tls_wrap.cc @@ -221,8 +221,10 @@ void TLSWrap::SSLInfoCallback(const SSL* ssl_, int where, int ret) { Local object = c->object(); if (where & SSL_CB_HANDSHAKE_START) { - Local callback = object->Get(env->onhandshakestart_string()); - if (callback->IsFunction()) { + Local callback; + + if (object->Get(env->context(), env->onhandshakestart_string()) + .ToLocal(&callback) && callback->IsFunction()) { Local argv[] = { env->GetNow() }; c->MakeCallback(callback.As(), arraysize(argv), argv); } @@ -232,9 +234,12 @@ void TLSWrap::SSLInfoCallback(const SSL* ssl_, int where, int ret) { // sending HelloRequest in OpenSSL-1.1.1. // We need to check whether this is in a renegotiation state or not. if (where & SSL_CB_HANDSHAKE_DONE && !SSL_renegotiate_pending(ssl)) { + Local callback; + c->established_ = true; - Local callback = object->Get(env->onhandshakedone_string()); - if (callback->IsFunction()) { + + if (object->Get(env->context(), env->onhandshakedone_string()) + .ToLocal(&callback) && callback->IsFunction()) { c->MakeCallback(callback.As(), 0, nullptr); } } @@ -845,7 +850,10 @@ int TLSWrap::SelectSNIContextCallback(SSL* s, int* ad, void* arg) { // Call the SNI callback and use its return value as context Local object = p->object(); - Local ctx = object->Get(env->sni_context_string()); + Local ctx; + + if (!object->Get(env->context(), env->sni_context_string()).ToLocal(&ctx)) + return SSL_TLSEXT_ERR_NOACK; // Not an object, probably undefined or null if (!ctx->IsObject())