From dad5aca9ff910344b961e8e1fc3bb14fb3bb5e55 Mon Sep 17 00:00:00 2001 From: AJ ONeal Date: Tue, 9 Aug 2016 15:19:29 -0400 Subject: [PATCH] add subject, altnames to cert-info --- lib/cert-info.js | 12 ++++++++---- lib/utils.js | 9 +++++---- 2 files changed, 13 insertions(+), 8 deletions(-) diff --git a/lib/cert-info.js b/lib/cert-info.js index b3e8cc7..fb90195 100644 --- a/lib/cert-info.js +++ b/lib/cert-info.js @@ -51,10 +51,14 @@ certInfo.getBasicInfo = function (pem) { sub = c.subject.types_and_values[0].value.value_block.value || null; return { - issuedAt: c.notBefore.value - , expiresAt: c.notAfter.value - , domains: domains - , subject: sub + subject: sub + , altnames: domains + // for debugging during console.log + // do not expect these values to be here + , _issuedAt: c.notBefore.value + , _expiresAt: c.notAfter.value + , issuedAt: new Date(c.notBefore.value).valueOf() + , expiresAt: new Date(c.notAfter.value).valueOf() }; }; diff --git a/lib/utils.js b/lib/utils.js index 69af35f..bf183ee 100644 --- a/lib/utils.js +++ b/lib/utils.js @@ -8,13 +8,14 @@ var PromiseA = require('bluebird'); var dns = PromiseA.promisifyAll(require('dns')); module.exports.attachCertInfo = function (results) { - var getCertInfo = require('./cert-info').getCertInfo; + var getCertInfo = require('./cert-info').getBasicInfo; // XXX Note: Parsing the certificate info comes at a great cost (~500kb) var certInfo = getCertInfo(results.cert); - //results.issuedAt = arr[3].mtime.valueOf() - results.issuedAt = Date(certInfo.notBefore.value).valueOf(); // Date.now() - results.expiresAt = Date(certInfo.notAfter.value).valueOf(); + // subject, altnames, issuedAt, expiresAt + Object.keys(certInfo).forEach(function (key) { + results[key] = certInfo[key]; + }); return results; };