summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorVitaly Dyatlov <md.xytop@gmail.com>2018-07-08 20:12:58 +0000
committerAnna Henningsen <anna@addaleax.net>2018-10-11 21:04:55 -0700
commit3f08c004c5c95abc8a2faf7e2ea156c72806b54b (patch)
tree590829ecbde95c45383b40b3dba953393daba194 /src
parente4dea40ce779ae03a77c194074e5aa06a8a28a78 (diff)
downloadandroid-node-v8-3f08c004c5c95abc8a2faf7e2ea156c72806b54b.tar.gz
android-node-v8-3f08c004c5c95abc8a2faf7e2ea156c72806b54b.tar.bz2
android-node-v8-3f08c004c5c95abc8a2faf7e2ea156c72806b54b.zip
src: revert removal of SecureContext `_external` getter
This `_external` getter is essential for some libs to work: uWebSockets as an example. PR-URL: https://github.com/nodejs/node/pull/21711 Reviewed-By: Anna Henningsen <anna@addaleax.net> Reviewed-By: James M Snell <jasnell@gmail.com>
Diffstat (limited to 'src')
-rw-r--r--src/node_crypto.cc21
-rw-r--r--src/node_crypto.h1
2 files changed, 22 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;
diff --git a/src/node_crypto.h b/src/node_crypto.h
index 63d85669fa..2ca333f3c2 100644
--- a/src/node_crypto.h
+++ b/src/node_crypto.h
@@ -165,6 +165,7 @@ class SecureContext : public BaseObject {
const v8::FunctionCallbackInfo<v8::Value>& args);
static void EnableTicketKeyCallback(
const v8::FunctionCallbackInfo<v8::Value>& args);
+ static void CtxGetter(const v8::FunctionCallbackInfo<v8::Value>& info);
template <bool primary>
static void GetCertificate(const v8::FunctionCallbackInfo<v8::Value>& args);