From 815c569674702b6bd46db79b2b7390caea9baa50 Mon Sep 17 00:00:00 2001 From: AJ ONeal Date: Tue, 9 Aug 2016 15:10:53 -0400 Subject: [PATCH] allow specifying cert path --- lib/cert-info.js | 15 ++++++++++----- 1 file changed, 10 insertions(+), 5 deletions(-) diff --git a/lib/cert-info.js b/lib/cert-info.js index 8672112..b3e8cc7 100644 --- a/lib/cert-info.js +++ b/lib/cert-info.js @@ -62,20 +62,20 @@ certInfo.getCertInfoFromFile = function (pemFile) { return require('fs').readFileSync(pemFile, 'ascii'); }; -certInfo.testGetCertInfo = function () { +certInfo.testGetCertInfo = function (pathname) { var path = require('path'); - var pemFile = path.join(__dirname, '..', 'tests', 'example.cert.pem'); + var pemFile = pathname || path.join(__dirname, '..', 'tests', 'example.cert.pem'); return certInfo.getCertInfo(certInfo.getCertInfoFromFile(pemFile)); }; -certInfo.testBasicCertInfo = function () { +certInfo.testBasicCertInfo = function (pathname) { var path = require('path'); - var pemFile = path.join(__dirname, '..', 'tests', 'example.cert.pem'); + var pemFile = pathname || path.join(__dirname, '..', 'tests', 'example.cert.pem'); return certInfo.getBasicInfo(certInfo.getCertInfoFromFile(pemFile)); }; if (require.main === module) { - var c = certInfo.testGetCertInfo(); + var c = certInfo.testGetCertInfo(process.argv[2]); console.info(''); @@ -88,4 +88,9 @@ if (require.main === module) { console.info(new Date(c.notAfter.value).valueOf()); console.info(''); + + var b = certInfo.testBasicCertInfo(process.argv[2]); + console.info(''); + console.info(JSON.stringify(b, null, ' ')); + console.info(''); }