Skip to content

Commit 26e2938

Browse files
Hannes-Magnusson-CKtargos
authored andcommitted
crypto: add cert.pubkey containing the raw pubkey of certificate
PR-URL: #17690 Reviewed-By: James M Snell <[email protected]> Reviewed-By: Ben Noordhuis <[email protected]> Reviewed-By: Ruben Bridgewater <[email protected]>
1 parent d1c45e2 commit 26e2938

File tree

2 files changed

+9
-0
lines changed

2 files changed

+9
-0
lines changed

src/env.h

+1
Original file line numberDiff line numberDiff line change
@@ -243,6 +243,7 @@ struct PackageConfig {
243243
V(preference_string, "preference") \
244244
V(priority_string, "priority") \
245245
V(produce_cached_data_string, "produceCachedData") \
246+
V(pubkey_string, "pubkey") \
246247
V(raw_string, "raw") \
247248
V(read_host_object_string, "_readHostObject") \
248249
V(readable_string, "readable") \

src/node_crypto.cc

+8
Original file line numberDiff line numberDiff line change
@@ -1924,6 +1924,14 @@ static Local<Object> X509ToObject(Environment* env, X509* cert) {
19241924
String::kNormalString,
19251925
mem->length)).FromJust();
19261926
USE(BIO_reset(bio));
1927+
1928+
int size = i2d_RSA_PUBKEY(rsa, nullptr);
1929+
CHECK_GE(size, 0);
1930+
Local<Object> pubbuff = Buffer::New(env, size).ToLocalChecked();
1931+
unsigned char* pubserialized =
1932+
reinterpret_cast<unsigned char*>(Buffer::Data(pubbuff));
1933+
i2d_RSA_PUBKEY(rsa, &pubserialized);
1934+
info->Set(env->pubkey_string(), pubbuff);
19271935
}
19281936

19291937
if (pkey != nullptr) {

0 commit comments

Comments
 (0)