allow specifying cert path

This commit is contained in:
AJ ONeal 2016-08-09 15:10:53 -04:00
parent f06d25ab22
commit 815c569674
1 changed files with 10 additions and 5 deletions

View File

@ -62,20 +62,20 @@ certInfo.getCertInfoFromFile = function (pemFile) {
return require('fs').readFileSync(pemFile, 'ascii'); return require('fs').readFileSync(pemFile, 'ascii');
}; };
certInfo.testGetCertInfo = function () { certInfo.testGetCertInfo = function (pathname) {
var path = require('path'); 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)); return certInfo.getCertInfo(certInfo.getCertInfoFromFile(pemFile));
}; };
certInfo.testBasicCertInfo = function () { certInfo.testBasicCertInfo = function (pathname) {
var path = require('path'); 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)); return certInfo.getBasicInfo(certInfo.getCertInfoFromFile(pemFile));
}; };
if (require.main === module) { if (require.main === module) {
var c = certInfo.testGetCertInfo(); var c = certInfo.testGetCertInfo(process.argv[2]);
console.info(''); console.info('');
@ -88,4 +88,9 @@ if (require.main === module) {
console.info(new Date(c.notAfter.value).valueOf()); console.info(new Date(c.notAfter.value).valueOf());
console.info(''); console.info('');
var b = certInfo.testBasicCertInfo(process.argv[2]);
console.info('');
console.info(JSON.stringify(b, null, ' '));
console.info('');
} }