Skip to content

Commit

Permalink
crypto: add cert.pubkey containing the raw pubkey of certificate
Browse files Browse the repository at this point in the history
PR-URL: #17690
Reviewed-By: James M Snell <[email protected]>
Reviewed-By: Ben Noordhuis <[email protected]>
Reviewed-By: Ruben Bridgewater <[email protected]>
  • Loading branch information
Hannes-Magnusson-CK authored and targos committed Mar 24, 2018
1 parent d1c45e2 commit 26e2938
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 0 deletions.
1 change: 1 addition & 0 deletions src/env.h
Original file line number Diff line number Diff line change
Expand Up @@ -243,6 +243,7 @@ struct PackageConfig {
V(preference_string, "preference") \
V(priority_string, "priority") \
V(produce_cached_data_string, "produceCachedData") \
V(pubkey_string, "pubkey") \
V(raw_string, "raw") \
V(read_host_object_string, "_readHostObject") \
V(readable_string, "readable") \
Expand Down
8 changes: 8 additions & 0 deletions src/node_crypto.cc
Original file line number Diff line number Diff line change
Expand Up @@ -1924,6 +1924,14 @@ static Local<Object> 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<Object> pubbuff = Buffer::New(env, size).ToLocalChecked();
unsigned char* pubserialized =
reinterpret_cast<unsigned char*>(Buffer::Data(pubbuff));
i2d_RSA_PUBKEY(rsa, &pubserialized);
info->Set(env->pubkey_string(), pubbuff);
}

if (pkey != nullptr) {
Expand Down

0 comments on commit 26e2938

Please sign in to comment.