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())