add certInfo to cert from file read

This commit is contained in:
AJ ONeal 2016-08-04 12:23:40 -04:00
parent 61ddeba8e2
commit baec7ed5c3
2 changed files with 10 additions and 3 deletions

View File

@ -89,13 +89,18 @@ module.exports.fetchFromDisk = function (args) {
// stat the file, not the link // stat the file, not the link
, fs.statAsync(args.certPath) // 3 , fs.statAsync(args.certPath) // 3
]).then(function (arr) { ]).then(function (arr) {
var cert = arr[1];
var getCertInfo = require('./cert-info').getCertInfo;
// XXX Note: Parsing the certificate info comes at a great cost (~500kb)
var certInfo = getCertInfo(cert);
return { return {
key: arr[0] // privkey.pem key: arr[0] // privkey.pem
, privkey: arr[0] // privkey.pem , privkey: arr[0] // privkey.pem
, fullchain: arr[1] + '\n' + arr[2] // fullchain.pem , fullchain: arr[1] + '\n' + arr[2] // fullchain.pem
, cert: arr[1] // cert.pem , cert: cert // cert.pem
, chain: arr[2] // chain.pem , chain: arr[2] // chain.pem
, ca: arr[2] // chain.pem , ca: arr[2] // chain.pem
@ -105,7 +110,9 @@ module.exports.fetchFromDisk = function (args) {
, certPath: args.certPath , certPath: args.certPath
, chainPath: args.chainPath , chainPath: args.chainPath
, issuedAt: arr[3].mtime.valueOf() // ??? TODO parse to determine expiresAt and lifetime //, issuedAt: arr[3].mtime.valueOf()
, issuedAt: Date(certInfo.notBefore.value).valueOf() // Date.now()
, expiresAt: Date(certInfo.notAfter.value).valueOf()
, lifetime: args.lifetime , lifetime: args.lifetime
}; };
}, function (err) { }, function (err) {

View File

@ -224,7 +224,7 @@ function writeCertificateAsync(args, defaults, handlers) {
}).then(function () { }).then(function () {
var getCertInfo = require('./cert-info').getCertInfo; var getCertInfo = require('./cert-info').getCertInfo;
// TODO on memory-constrained systems this is a bad idea // XXX Note: Parsing the certificate info comes at a great cost (~500kb)
var certInfo = getCertInfo(result.cert); var certInfo = getCertInfo(result.cert);
return { return {