From 6b8e27f693b1a131a6d771e6caaa677c45ffeb72 Mon Sep 17 00:00:00 2001 From: Jan Kryl Date: Mon, 30 Jan 2017 09:46:02 +0100 Subject: [PATCH] Support for subject hash property of a certificate --- src/x509.cc | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/src/x509.cc b/src/x509.cc index 7606b9f..c82e98f 100644 --- a/src/x509.cc +++ b/src/x509.cc @@ -1,4 +1,5 @@ #include +#include #include using namespace v8; @@ -236,6 +237,13 @@ Local try_parse(const std::string& dataString) { Nan::New("notAfter").ToLocalChecked(), parse_date(X509_get_notAfter(cert))); + // Subject hash + std::stringstream stream; + stream << std::hex << X509_subject_name_hash(cert); + Nan::Set(exports, + Nan::New("subjectHash").ToLocalChecked(), + Nan::New(stream.str()).ToLocalChecked()); + // Signature Algorithm int sig_alg_nid = OBJ_obj2nid(cert->sig_alg->algorithm); if (sig_alg_nid == NID_undef) {