move attachCertInfo to utils.js

This commit is contained in:
AJ ONeal 2016-08-06 01:32:59 -04:00
parent ae91c08dd1
commit a0d01815df
1 changed files with 12 additions and 0 deletions

View File

@ -5,6 +5,18 @@ var homeRe = new RegExp("^~(\\/|\\\|\\" + path.sep + ")");
var re = /^[a-zA-Z0-9\.\-]+$/; var re = /^[a-zA-Z0-9\.\-]+$/;
var punycode = require('punycode'); var punycode = require('punycode');
module.exports.attachCertInfo = function (results) {
var getCertInfo = require('./cert-info').getCertInfo;
// 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();
return results;
};
module.exports.isValidDomain = function (domain) { module.exports.isValidDomain = function (domain) {
if (re.test(domain)) { if (re.test(domain)) {
return domain; return domain;