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: nodejs#17690
Reviewed-By: James M Snell <jasnell@gmail.com>
Reviewed-By: Ben Noordhuis <info@bnoordhuis.nl>
Reviewed-By: Ruben Bridgewater <ruben@bridgewater.de>
  • Loading branch information
Hannes-Magnusson-CK authored and MayaLekova committed May 8, 2018
1 parent b2e6856 commit 4fb7a07
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 @@ -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") \
Expand Down
8 changes: 8 additions & 0 deletions src/node_crypto.cc
Original file line number Diff line number Diff line change
Expand Up @@ -1898,6 +1898,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 4fb7a07

Please sign in to comment.