Skip to content

Commit 5a6beb7

Browse files
Hannes-Magnusson-CKBridgeAR
authored andcommitted
crypto: add cert.pubkey containing the raw pubkey of certificate
PR-URL: nodejs#17690 Reviewed-By: James M Snell <jasnell@gmail.com> Reviewed-By: Ben Noordhuis <info@bnoordhuis.nl> Reviewed-By: Ruben Bridgewater <ruben@bridgewater.de>
1 parent 7876aeb commit 5a6beb7

File tree

2 files changed

+9
-0
lines changed

2 files changed

+9
-0
lines changed

src/env.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -242,6 +242,7 @@ struct PackageConfig {
242242
V(priority_string, "priority") \
243243
V(produce_cached_data_string, "produceCachedData") \
244244
V(promise_string, "promise") \
245+
V(pubkey_string, "pubkey") \
245246
V(raw_string, "raw") \
246247
V(read_host_object_string, "_readHostObject") \
247248
V(readable_string, "readable") \

src/node_crypto.cc

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1898,6 +1898,14 @@ static Local<Object> X509ToObject(Environment* env, X509* cert) {
18981898
String::kNormalString,
18991899
mem->length)).FromJust();
19001900
USE(BIO_reset(bio));
1901+
1902+
int size = i2d_RSA_PUBKEY(rsa, nullptr);
1903+
CHECK_GE(size, 0);
1904+
Local<Object> pubbuff = Buffer::New(env, size).ToLocalChecked();
1905+
unsigned char* pubserialized =
1906+
reinterpret_cast<unsigned char*>(Buffer::Data(pubbuff));
1907+
i2d_RSA_PUBKEY(rsa, &pubserialized);
1908+
info->Set(env->pubkey_string(), pubbuff);
19011909
}
19021910

19031911
if (pkey != nullptr) {

0 commit comments

Comments
 (0)