diff options
Diffstat (limited to 'src/node_crypto.cc')
-rw-r--r-- | src/node_crypto.cc | 21 |
1 files changed, 21 insertions, 0 deletions
diff --git a/src/node_crypto.cc b/src/node_crypto.cc index 9b22edfb96..dd7e0c8468 100644 --- a/src/node_crypto.cc +++ b/src/node_crypto.cc @@ -359,6 +359,19 @@ void SecureContext::Initialize(Environment* env, Local<Object> target) { t->Set(FIXED_ONE_BYTE_STRING(env->isolate(), "kTicketKeyIVIndex"), Integer::NewFromUnsigned(env->isolate(), kTicketKeyIVIndex)); + Local<FunctionTemplate> ctx_getter_templ = + FunctionTemplate::New(env->isolate(), + CtxGetter, + env->as_external(), + Signature::New(env->isolate(), t)); + + + t->PrototypeTemplate()->SetAccessorProperty( + FIXED_ONE_BYTE_STRING(env->isolate(), "_external"), + ctx_getter_templ, + Local<FunctionTemplate>(), + static_cast<PropertyAttribute>(ReadOnly | DontDelete)); + target->Set(secureContextString, t->GetFunction(env->context()).ToLocalChecked()); env->set_secure_context_constructor_template(t); @@ -1331,6 +1344,14 @@ int SecureContext::TicketCompatibilityCallback(SSL* ssl, } +void SecureContext::CtxGetter(const FunctionCallbackInfo<Value>& info) { + SecureContext* sc; + ASSIGN_OR_RETURN_UNWRAP(&sc, info.This()); + Local<External> ext = External::New(info.GetIsolate(), sc->ctx_.get()); + info.GetReturnValue().Set(ext); +} + + template <bool primary> void SecureContext::GetCertificate(const FunctionCallbackInfo<Value>& args) { SecureContext* wrap; |