From 42eb0c3eae9582199f5fbf757835b7f06a1993d1 Mon Sep 17 00:00:00 2001 From: Anthony Tseng Date: Sat, 16 Jul 2016 02:09:02 +0800 Subject: [PATCH] serial number in hex string --- atom/common/native_mate_converters/net_converter.cc | 11 ++++++++++- docs/api/app.md | 12 ++++++------ docs/api/web-contents.md | 12 ++++++------ 3 files changed, 22 insertions(+), 13 deletions(-) diff --git a/atom/common/native_mate_converters/net_converter.cc b/atom/common/native_mate_converters/net_converter.cc index b88efbae0045..667a977df608 100644 --- a/atom/common/native_mate_converters/net_converter.cc +++ b/atom/common/native_mate_converters/net_converter.cc @@ -6,6 +6,7 @@ #include #include +#include #include "atom/common/node_includes.h" #include "atom/common/native_mate_converters/gurl_converter.h" @@ -17,6 +18,7 @@ #include "net/base/upload_element_reader.h" #include "net/base/upload_file_element_reader.h" #include "net/cert/x509_certificate.h" +#include "net/der/parse_values.h" #include "net/http/http_response_headers.h" #include "net/url_request/url_request.h" @@ -47,7 +49,14 @@ v8::Local Converter>::ToV8( dict.Set("data", buffer); dict.Set("issuerName", val->issuer().GetDisplayName()); dict.Set("subjectName", val->subject().GetDisplayName()); - dict.Set("serialNumber", val->serial_number()); + uint64_t serial_number; + if (net::der::ParseUint64(net::der::Input(&val->serial_number()), &serial_number)) { + std::stringstream stream; + stream << std::hex << serial_number; + dict.Set("serialNumber", stream.str()); + } else { + dict.Set("serialNumber", std::string()); + } dict.Set("validStart", val->valid_start().ToDoubleT()); dict.Set("validExpiry", val->valid_expiry().ToDoubleT()); dict.Set("fingerprint", diff --git a/docs/api/app.md b/docs/api/app.md index 76f3caa2439d..114ac8c5e09b 100644 --- a/docs/api/app.md +++ b/docs/api/app.md @@ -181,9 +181,9 @@ Returns: * `data` Buffer - PEM encoded data * `issuerName` String - Issuer's Common Name * `subjectName` String - Subject's Common Name - * `serialNumber` Buffer - DER encoded data - * `validStart` Integer - Start date of the certificate being valid - * `validExpiry` Integer - End date of the certificate being valid + * `serialNumber` String - Hex value represented string + * `validStart` Integer - Start date of the certificate being valid in seconds + * `validExpiry` Integer - End date of the certificate being valid in seconds * `fingerprint` String - Fingerprint of the certificate * `callback` Function @@ -214,9 +214,9 @@ Returns: * `data` Buffer - PEM encoded data * `issuerName` String - Issuer's Common Name * `subjectName` String - Subject's Common Name - * `serialNumber` - DER encoded data - * `validStart` Integer - Start date of the certificate being valid - * `validExpiry` Integer - End date of the certificate being valid + * `serialNumber` String - Hex value represented string + * `validStart` Integer - Start date of the certificate being valid in seconds + * `validExpiry` Integer - End date of the certificate being valid in seconds * `fingerprint` String - Fingerprint of the certificate * `callback` Function diff --git a/docs/api/web-contents.md b/docs/api/web-contents.md index 7e3a95422288..ad53ae79de3f 100644 --- a/docs/api/web-contents.md +++ b/docs/api/web-contents.md @@ -231,9 +231,9 @@ Returns: * `data` Buffer - PEM encoded data * `issuerName` String - Issuer's Common Name * `subjectName` String - Subject's Common Name - * `serialNumber` - DER encoded data - * `validStart` Integer - Start date of the certificate being valid - * `validExpiry` Integer - End date of the certificate being valid + * `serialNumber` String - Hex value represented string + * `validStart` Integer - Start date of the certificate being valid in seconds + * `validExpiry` Integer - End date of the certificate being valid in seconds * `fingerprint` String - Fingerprint of the certificate * `callback` Function @@ -252,9 +252,9 @@ Returns: * `data` Buffer - PEM encoded data * `issuerName` String - Issuer's Common Name * `subjectName` String - Subject's Common Name - * `serialNumber` - DER encoded data - * `validStart` Integer - Start date of the certificate being valid - * `validExpiry` Integer - End date of the certificate being valid + * `serialNumber` String - Hex value represented string + * `validStart` Integer - Start date of the certificate being valid in seconds + * `validExpiry` Integer - End date of the certificate being valid in seconds * `fingerprint` String - Fingerprint of the certificate * `callback` Function