crypto: add cert.pubkey containing the raw pubkey of certificate

PR-URL: https://github.com/nodejs/node/pull/17690
Reviewed-By: James M Snell <jasnell@gmail.com>
Reviewed-By: Ben Noordhuis <info@bnoordhuis.nl>
Reviewed-By: Ruben Bridgewater <ruben@bridgewater.de>
This commit is contained in:
Hannes Magnusson 2018-02-06 21:34:08 -08:00 committed by Ruben Bridgewater
parent 7876aeb0fe
commit 5a6beb7741
No known key found for this signature in database
GPG Key ID: F07496B3EB3C1762
2 changed files with 9 additions and 0 deletions

View File

@ -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") \

View File

@ -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) {