serial number in hex string

This commit is contained in:
Anthony Tseng 2016-07-16 02:09:02 +08:00
parent 4081381700
commit 42eb0c3eae
3 changed files with 22 additions and 13 deletions

View file

@ -6,6 +6,7 @@
#include <string>
#include <vector>
#include <iomanip>
#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<v8::Value> Converter<scoped_refptr<net::X509Certificate>>::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",

View file

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

View file

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