diff --git a/src/env.h b/src/env.h index a4454d55c1c..4df4cb13b82 100644 --- a/src/env.h +++ b/src/env.h @@ -242,6 +242,7 @@ struct PackageConfig { V(priority_string, "priority") \ V(produce_cached_data_string, "produceCachedData") \ V(promise_string, "promise") \ + V(pubkey_string, "pubkey") \ V(raw_string, "raw") \ V(read_host_object_string, "_readHostObject") \ V(readable_string, "readable") \ diff --git a/src/node_crypto.cc b/src/node_crypto.cc index 202de9cf675..a21e37408de 100644 --- a/src/node_crypto.cc +++ b/src/node_crypto.cc @@ -1898,6 +1898,14 @@ static Local X509ToObject(Environment* env, X509* cert) { String::kNormalString, mem->length)).FromJust(); USE(BIO_reset(bio)); + + int size = i2d_RSA_PUBKEY(rsa, nullptr); + CHECK_GE(size, 0); + Local pubbuff = Buffer::New(env, size).ToLocalChecked(); + unsigned char* pubserialized = + reinterpret_cast(Buffer::Data(pubbuff)); + i2d_RSA_PUBKEY(rsa, &pubserialized); + info->Set(env->pubkey_string(), pubbuff); } if (pkey != nullptr) {