Comparing version 1.4.5 to 1.4.6
557
lib/pem.js
@@ -1,14 +0,14 @@ | ||
"use strict"; | ||
'use strict'; | ||
var spawn = require("child_process").spawn, | ||
os = require("os"), | ||
pathlib = require("path"), | ||
fs = require("fs"), | ||
net = require("net"), | ||
crypto = require("crypto"), | ||
var spawn = require('child_process').spawn, | ||
os = require('os'), | ||
pathlib = require('path'), | ||
fs = require('fs'), | ||
net = require('net'), | ||
crypto = require('crypto'), | ||
pathOpenSSL, | ||
tempDir = process.env.PEMJS_TMPDIR || (os.tmpdir || os.tmpDir) && (os.tmpdir || os.tmpDir)() || "/tmp"; | ||
tempDir = process.env.PEMJS_TMPDIR || (os.tmpdir || os.tmpDir) && (os.tmpdir || os.tmpDir)() || '/tmp'; | ||
module.exports.createPrivateKey = createPrivateKey; | ||
module.exports.createCSR =createCSR; | ||
module.exports.createCSR = createCSR; | ||
module.exports.createCertificate = createCertificate; | ||
@@ -29,4 +29,4 @@ module.exports.readCertificateInfo = readCertificateInfo; | ||
*/ | ||
function createPrivateKey(keyBitsize, callback){ | ||
if(!callback && typeof keyBitsize == "function"){ | ||
function createPrivateKey(keyBitsize, callback) { | ||
if (!callback && typeof keyBitsize === 'function') { | ||
callback = keyBitsize; | ||
@@ -38,13 +38,15 @@ keyBitsize = undefined; | ||
var params = ["genrsa", | ||
"-rand", | ||
"/var/log/mail:/var/log/messages", | ||
keyBitsize | ||
]; | ||
var params = ['genrsa', | ||
'-rand', | ||
'/var/log/mail:/var/log/messages', | ||
keyBitsize | ||
]; | ||
execOpenSSL(params, "RSA PRIVATE KEY", function(error, key){ | ||
if(error){ | ||
execOpenSSL(params, 'RSA PRIVATE KEY', function(error, key) { | ||
if (error) { | ||
return callback(error); | ||
} | ||
return callback(null, {key: key}); | ||
return callback(null, { | ||
key: key | ||
}); | ||
}); | ||
@@ -68,3 +70,3 @@ } | ||
* @param {String} [options.organizationUnit] CSR organizational unit field | ||
* @param {String} [options.commonName="localhost"] CSR common name field | ||
* @param {String} [options.commonName='localhost'] CSR common name field | ||
* @param {String} [options.emailAddress] CSR email address field | ||
@@ -76,4 +78,4 @@ * @param {Array} [options.altNames] is a list of subjectAltNames in the subjectAltName field | ||
function createCSR(options, callback){ | ||
if(!callback && typeof options == "function"){ | ||
function createCSR(options, callback) { | ||
if (!callback && typeof options === 'function') { | ||
callback = options; | ||
@@ -89,3 +91,3 @@ options = undefined; | ||
options.altNames = [options.commonName]; | ||
} else if (options.altNames.indexOf(options.commonName) == -1) { | ||
} else if (options.altNames.indexOf(options.commonName) === -1) { | ||
options.altNames = options.altNames.concat([options.commonName]); | ||
@@ -95,5 +97,5 @@ } | ||
if(!options.clientKey){ | ||
createPrivateKey(options.keyBitsize || 2048, function(error, keyData){ | ||
if(error){ | ||
if (!options.clientKey) { | ||
createPrivateKey(options.keyBitsize || 2048, function(error, keyData) { | ||
if (error) { | ||
return callback(error); | ||
@@ -107,10 +109,10 @@ } | ||
var params = ["req", | ||
"-new", | ||
"-" + (options.hash || "sha256"), | ||
"-subj", | ||
generateCSRSubject(options), | ||
"-key", | ||
"--TMPFILE--" | ||
]; | ||
var params = ['req', | ||
'-new', | ||
'-' + (options.hash || 'sha256'), | ||
'-subj', | ||
generateCSRSubject(options), | ||
'-key', | ||
'--TMPFILE--' | ||
]; | ||
var tmpfiles = [options.clientKey]; | ||
@@ -120,34 +122,34 @@ var config = null; | ||
if (options.altNames) { | ||
params.push("-extensions"); | ||
params.push("v3_req"); | ||
params.push("-config"); | ||
params.push("--TMPFILE--"); | ||
params.push('-extensions'); | ||
params.push('v3_req'); | ||
params.push('-config'); | ||
params.push('--TMPFILE--'); | ||
var altNamesRep = []; | ||
for (var i = 0; i < options.altNames.length; i++) { | ||
altNamesRep.push((net.isIP(options.altNames[i]) ? "IP" : "DNS") + "." + (i+1) + " = " + options.altNames[i]); | ||
altNamesRep.push((net.isIP(options.altNames[i]) ? 'IP' : 'DNS') + '.' + (i + 1) + ' = ' + options.altNames[i]); | ||
} | ||
tmpfiles.push(config = [ | ||
"[req]", | ||
"req_extensions = v3_req", | ||
"distinguished_name = req_distinguished_name", | ||
"[v3_req]", | ||
"subjectAltName = @alt_names", | ||
"[alt_names]", | ||
altNamesRep.join("\n"), | ||
"[req_distinguished_name]", | ||
"commonName = Common Name", | ||
"commonName_max = 64", | ||
].join("\n")); | ||
'[req]', | ||
'req_extensions = v3_req', | ||
'distinguished_name = req_distinguished_name', | ||
'[v3_req]', | ||
'subjectAltName = @alt_names', | ||
'[alt_names]', | ||
altNamesRep.join('\n'), | ||
'[req_distinguished_name]', | ||
'commonName = Common Name', | ||
'commonName_max = 64', | ||
].join('\n')); | ||
} | ||
execOpenSSL(params, "CERTIFICATE REQUEST", tmpfiles, function(error, data){ | ||
if(error){ | ||
execOpenSSL(params, 'CERTIFICATE REQUEST', tmpfiles, function(error, data) { | ||
if (error) { | ||
return callback(error); | ||
} | ||
var response = { | ||
csr: data, | ||
config: config, | ||
clientKey: options.clientKey | ||
}; | ||
csr: data, | ||
config: config, | ||
clientKey: options.clientKey | ||
}; | ||
return callback(null, response); | ||
@@ -171,4 +173,4 @@ | ||
*/ | ||
function createCertificate(options, callback){ | ||
if(!callback && typeof options == "function"){ | ||
function createCertificate(options, callback) { | ||
if (!callback && typeof options === 'function') { | ||
callback = options; | ||
@@ -180,5 +182,5 @@ options = undefined; | ||
if(!options.csr){ | ||
createCSR(options, function(error, keyData){ | ||
if(error){ | ||
if (!options.csr) { | ||
createCSR(options, function(error, keyData) { | ||
if (error) { | ||
return callback(error); | ||
@@ -194,9 +196,9 @@ } | ||
if(!options.serviceKey){ | ||
if (!options.serviceKey) { | ||
if(options.selfSigned){ | ||
if (options.selfSigned) { | ||
options.serviceKey = options.clientKey; | ||
}else{ | ||
createPrivateKey(options.keyBitsize || 2048, function(error, keyData){ | ||
if(error){ | ||
} else { | ||
createPrivateKey(options.keyBitsize || 2048, function(error, keyData) { | ||
if (error) { | ||
return callback(error); | ||
@@ -211,10 +213,10 @@ } | ||
var params = ["x509", | ||
"-req", | ||
"-" + (options.hash || "sha256"), | ||
"-days", | ||
Number(options.days) || "365", | ||
"-in", | ||
"--TMPFILE--" | ||
]; | ||
var params = ['x509', | ||
'-req', | ||
'-' + (options.hash || 'sha256'), | ||
'-days', | ||
Number(options.days) || '365', | ||
'-in', | ||
'--TMPFILE--' | ||
]; | ||
var tmpfiles = [options.csr]; | ||
@@ -224,15 +226,15 @@ | ||
if (!options.serial) { | ||
return callback(new Error("serial option required for CA signing")); | ||
return callback(new Error('serial option required for CA signing')); | ||
} | ||
params.push("-CA"); | ||
params.push("--TMPFILE--"); | ||
params.push("-CAkey"); | ||
params.push("--TMPFILE--"); | ||
params.push("-set_serial"); | ||
params.push("0x" + ("00000000" + options.serial.toString(16)).slice(-8)); | ||
params.push('-CA'); | ||
params.push('--TMPFILE--'); | ||
params.push('-CAkey'); | ||
params.push('--TMPFILE--'); | ||
params.push('-set_serial'); | ||
params.push('0x' + ('00000000' + options.serial.toString(16)).slice(-8)); | ||
tmpfiles.push(options.serviceCertificate); | ||
tmpfiles.push(options.serviceKey); | ||
} else { | ||
params.push("-signkey"); | ||
params.push("--TMPFILE--"); | ||
params.push('-signkey'); | ||
params.push('--TMPFILE--'); | ||
tmpfiles.push(options.serviceKey); | ||
@@ -242,19 +244,19 @@ } | ||
if (options.config) { | ||
params.push("-extensions"); | ||
params.push("v3_req"); | ||
params.push("-extfile"); | ||
params.push("--TMPFILE--"); | ||
params.push('-extensions'); | ||
params.push('v3_req'); | ||
params.push('-extfile'); | ||
params.push('--TMPFILE--'); | ||
tmpfiles.push(options.config); | ||
} | ||
execOpenSSL(params, "CERTIFICATE", tmpfiles, function(error, data){ | ||
if(error){ | ||
execOpenSSL(params, 'CERTIFICATE', tmpfiles, function(error, data) { | ||
if (error) { | ||
return callback(error); | ||
} | ||
var response = { | ||
csr: options.csr, | ||
clientKey: options.clientKey, | ||
certificate: data, | ||
serviceKey: options.serviceKey | ||
}; | ||
csr: options.csr, | ||
clientKey: options.clientKey, | ||
certificate: data, | ||
serviceKey: options.serviceKey | ||
}; | ||
return callback(null, response); | ||
@@ -270,4 +272,4 @@ }); | ||
*/ | ||
function getPublicKey(certificate, callback){ | ||
if(!callback && typeof certificate == "function"){ | ||
function getPublicKey(certificate, callback) { | ||
if (!callback && typeof certificate === 'function') { | ||
callback = certificate; | ||
@@ -277,30 +279,35 @@ certificate = undefined; | ||
certificate = (certificate || "").toString(); | ||
certificate = (certificate || '').toString(); | ||
var params; | ||
if(certificate.match(/BEGIN(\sNEW)? CERTIFICATE REQUEST/)){ | ||
params = ["req", | ||
"-in", | ||
"--TMPFILE--", | ||
"-pubkey", | ||
"-noout"]; | ||
}else if(certificate.match(/BEGIN RSA PRIVATE KEY/)){ | ||
params = ["rsa", | ||
"-in", | ||
"--TMPFILE--", | ||
"-pubout"]; | ||
}else{ | ||
params = ["x509", | ||
"-in", | ||
"--TMPFILE--", | ||
"-pubkey", | ||
"-noout"]; | ||
if (certificate.match(/BEGIN(\sNEW)? CERTIFICATE REQUEST/)) { | ||
params = ['req', | ||
'-in', | ||
'--TMPFILE--', | ||
'-pubkey', | ||
'-noout' | ||
]; | ||
} else if (certificate.match(/BEGIN RSA PRIVATE KEY/)) { | ||
params = ['rsa', | ||
'-in', | ||
'--TMPFILE--', | ||
'-pubout' | ||
]; | ||
} else { | ||
params = ['x509', | ||
'-in', | ||
'--TMPFILE--', | ||
'-pubkey', | ||
'-noout' | ||
]; | ||
} | ||
execOpenSSL(params, "PUBLIC KEY", certificate, function(error, key){ | ||
if(error){ | ||
execOpenSSL(params, 'PUBLIC KEY', certificate, function(error, key) { | ||
if (error) { | ||
return callback(error); | ||
} | ||
return callback(null, {publicKey: key}); | ||
return callback(null, { | ||
publicKey: key | ||
}); | ||
}); | ||
@@ -315,4 +322,4 @@ } | ||
*/ | ||
function readCertificateInfo(certificate, callback){ | ||
if(!callback && typeof certificate == "function"){ | ||
function readCertificateInfo(certificate, callback) { | ||
if (!callback && typeof certificate === 'function') { | ||
callback = certificate; | ||
@@ -322,12 +329,12 @@ certificate = undefined; | ||
certificate = (certificate || "").toString(); | ||
certificate = (certificate || '').toString(); | ||
var type = certificate.match(/BEGIN(\sNEW)? CERTIFICATE REQUEST/)?"req":"x509", | ||
var type = certificate.match(/BEGIN(\sNEW)? CERTIFICATE REQUEST/) ? 'req' : 'x509', | ||
params = [type, | ||
"-noout", | ||
"-text", | ||
"-in", | ||
"--TMPFILE--" | ||
]; | ||
spawnWrapper(params, certificate, function(err, code, stdout){ | ||
'-noout', | ||
'-text', | ||
'-in', | ||
'--TMPFILE--' | ||
]; | ||
spawnWrapper(params, certificate, function(err, code, stdout) { | ||
if (err) { | ||
@@ -346,20 +353,20 @@ return callback(err); | ||
*/ | ||
function getModulus(certificate, callback){ | ||
function getModulus(certificate, callback) { | ||
certificate = Buffer.isBuffer(certificate) && certificate.toString() || certificate; | ||
var type = ""; | ||
if ( certificate.match(/BEGIN(\sNEW)? CERTIFICATE REQUEST/)){ | ||
type="req"; | ||
}else if ( certificate.match(/BEGIN RSA PRIVATE KEY/)){ | ||
type="rsa"; | ||
}else { | ||
type="x509"; | ||
var type = ''; | ||
if (certificate.match(/BEGIN(\sNEW)? CERTIFICATE REQUEST/)) { | ||
type = 'req'; | ||
} else if (certificate.match(/BEGIN RSA PRIVATE KEY/)) { | ||
type = 'rsa'; | ||
} else { | ||
type = 'x509'; | ||
} | ||
var params = [type, | ||
"-noout", | ||
"-modulus", | ||
"-in", | ||
"--TMPFILE--" | ||
'-noout', | ||
'-modulus', | ||
'-in', | ||
'--TMPFILE--' | ||
]; | ||
spawnWrapper(params, certificate, function(err, code, stdout){ | ||
spawnWrapper(params, certificate, function(err, code, stdout) { | ||
if (err) { | ||
@@ -369,6 +376,8 @@ return callback(err); | ||
var match = stdout.match(/Modulus=([0-9a-fA-F]+)$/m); | ||
if (match){ | ||
return callback(null, {modulus: match[1]}); | ||
if (match) { | ||
return callback(null, { | ||
modulus: match[1] | ||
}); | ||
} else { | ||
return callback(new Error("No modulus")); | ||
return callback(new Error('No modulus')); | ||
} | ||
@@ -382,4 +391,4 @@ }); | ||
*/ | ||
function config(options){ | ||
if (options.pathOpenSSL){ | ||
function config(options) { | ||
if (options.pathOpenSSL) { | ||
pathOpenSSL = options.pathOpenSSL; | ||
@@ -395,10 +404,11 @@ } | ||
*/ | ||
function getFingerprint(certificate, callback){ | ||
var params = ["x509", | ||
"-in", | ||
"--TMPFILE--", | ||
"-fingerprint", | ||
"-noout"]; | ||
function getFingerprint(certificate, callback) { | ||
var params = ['x509', | ||
'-in', | ||
'--TMPFILE--', | ||
'-fingerprint', | ||
'-noout' | ||
]; | ||
spawnWrapper(params, certificate, function(err, code, stdout){ | ||
spawnWrapper(params, certificate, function(err, code, stdout) { | ||
if (err) { | ||
@@ -408,6 +418,8 @@ return callback(err); | ||
var match = stdout.match(/Fingerprint=([0-9a-fA-F:]+)$/m); | ||
if (match){ | ||
return callback(null, {fingerprint: match[1]}); | ||
if (match) { | ||
return callback(null, { | ||
fingerprint: match[1] | ||
}); | ||
} else { | ||
return callback(new Error("No fingerprint")); | ||
return callback(new Error('No fingerprint')); | ||
} | ||
@@ -419,55 +431,62 @@ }); | ||
function fetchCertificateData(certData, callback){ | ||
certData = (certData || "").toString(); | ||
function fetchCertificateData(certData, callback) { | ||
certData = (certData || '').toString(); | ||
var subject,subject2, extra, tmp, certValues = {}; | ||
var subject, subject2, extra, tmp, certValues = {}; | ||
var validity = {}; | ||
var san; | ||
if((subject = certData.match(/Subject:([^\n]*)\n/)) && subject.length>1){ | ||
subject2 = linebrakes(subject[1]+'\n'); | ||
if ((subject = certData.match(/Subject:([^\n]*)\n/)) && subject.length > 1) { | ||
subject2 = linebrakes(subject[1] + '\n'); | ||
subject = subject[1]; | ||
extra = subject.split("/"); | ||
subject = extra.shift()+"\n"; | ||
extra = extra.join("/")+"\n"; | ||
extra = subject.split('/'); | ||
subject = extra.shift() + '\n'; | ||
extra = extra.join('/') + '\n'; | ||
// country | ||
tmp = subject2.match(/\sC=([^\n].*?)[\n]/); | ||
certValues.country = tmp && tmp[1] || ""; | ||
certValues.country = tmp && tmp[1] || ''; | ||
// state | ||
tmp = subject2.match(/\sST=([^\n].*?)[\n]/); | ||
certValues.state = tmp && tmp[1] || ""; | ||
certValues.state = tmp && tmp[1] || ''; | ||
// locality | ||
tmp = subject2.match(/\sL=([^\n].*?)[\n]/); | ||
certValues.locality = tmp && tmp[1] || ""; | ||
certValues.locality = tmp && tmp[1] || ''; | ||
// organization | ||
tmp = subject2.match(/\sO=([^\n].*?)[\n]/); | ||
certValues.organization = tmp && tmp[1] || ""; | ||
certValues.organization = tmp && tmp[1] || ''; | ||
// unit | ||
tmp = subject2.match(/\sOU=([^\n].*?)[\n]/); | ||
certValues.organizationUnit = tmp && tmp[1] || ""; | ||
certValues.organizationUnit = tmp && tmp[1] || ''; | ||
// common name | ||
tmp = subject2.match(/\sCN=([^\n].*?)[\n]/); | ||
certValues.commonName = tmp && tmp[1] || ""; | ||
certValues.commonName = tmp && tmp[1] || ''; | ||
tmp = extra.match(/emailAddress=([^\n\/].*?)[\n\/]/); | ||
certValues.emailAddress = tmp && tmp[1] || ""; | ||
certValues.emailAddress = tmp && tmp[1] || ''; | ||
} | ||
if((san = certData.match(/X509v3 Subject Alternative Name: \n([^\n]*)\n/)) && san.length>1){ | ||
san = san[1].trim()+'\n'; | ||
if ((san = certData.match(/X509v3 Subject Alternative Name: \n([^\n]*)\n/)) && san.length > 1) { | ||
san = san[1].trim() + '\n'; | ||
certValues.san = {}; | ||
// country | ||
tmp = preg_match_all('DNS:([^,\\n].*?)[,\\n]',san); | ||
certValues.san.dns = tmp || ""; | ||
tmp = preg_match_all('DNS:([^,\\n].*?)[,\\n]', san); | ||
certValues.san.dns = tmp || ''; | ||
// country | ||
tmp = preg_match_all('IP Address:([^,\\n].*?)[,\\n\\s]',san); | ||
certValues.san.ip = tmp || ""; | ||
tmp = preg_match_all('IP Address:([^,\\n].*?)[,\\n\\s]', san); | ||
certValues.san.ip = tmp || ''; | ||
} | ||
if ((tmp = certData.match(/Not Before\s?:\s?([^\n]*)\n/)) && tmp.length>1) | ||
validity.start = Date.parse(tmp && tmp[1] || ""); | ||
if ((tmp = certData.match(/Not After\s?:\s?([^\n]*)\n/)) && tmp.length>1) | ||
validity.end = Date.parse(tmp && tmp[1] || ""); | ||
if (validity.start && validity.end) | ||
certValues.validity = validity; | ||
if ((tmp = certData.match(/Not Before\s?:\s?([^\n]*)\n/)) && tmp.length > 1) { | ||
validity.start = Date.parse(tmp && tmp[1] || ''); | ||
} | ||
if ((tmp = certData.match(/Not After\s?:\s?([^\n]*)\n/)) && tmp.length > 1) { | ||
validity.end = Date.parse(tmp && tmp[1] || ''); | ||
} | ||
if (validity.start && validity.end) { | ||
certValues.validity = validity; | ||
} | ||
callback(null, certValues); | ||
@@ -477,37 +496,37 @@ } | ||
function linebrakes (content){ | ||
var helper_x, p,subject; | ||
helper_x = content.replace(/(C|L|O|OU|ST|CN)=/g, "\n$1="); | ||
helper_x = preg_match_all('((C|L|O|OU|ST|CN)=[^\n].*)',helper_x); | ||
for(p in helper_x){ | ||
subject = helper_x[p].trim(); | ||
content = subject.split("/"); | ||
subject = content.shift(); | ||
helper_x[p] = rtrim(subject,','); | ||
function linebrakes(content) { | ||
var helper_x, p, subject; | ||
helper_x = content.replace(/(C|L|O|OU|ST|CN)=/g, '\n$1='); | ||
helper_x = preg_match_all('((C|L|O|OU|ST|CN)=[^\n].*)', helper_x); | ||
for (p in helper_x) { | ||
subject = helper_x[p].trim(); | ||
content = subject.split('/'); | ||
subject = content.shift(); | ||
helper_x[p] = rtrim(subject, ','); | ||
} | ||
return ' ' + helper_x.join('\n') + '\n'; | ||
} | ||
return " " + helper_x.join('\n') + "\n"; | ||
} | ||
function rtrim(str, charlist) { | ||
charlist = !charlist ? ' \\s\u00A0' : (charlist + '') | ||
.replace(/([\[\]\(\)\.\?\/\*\{\}\+\$\^\:])/g, '\\$1'); | ||
var re = new RegExp('[' + charlist + ']+$', 'g'); | ||
return (str + '') | ||
.replace(re, ''); | ||
charlist = !charlist ? ' \\s\u00A0' : (charlist + '') | ||
.replace(/([\[\]\(\)\.\?\/\*\{\}\+\$\^\:])/g, '\\$1'); | ||
var re = new RegExp('[' + charlist + ']+$', 'g'); | ||
return (str + '') | ||
.replace(re, ''); | ||
} | ||
function preg_match_all(regex, haystack) { | ||
var globalRegex = new RegExp(regex, 'g'); | ||
var globalMatch = haystack.match(globalRegex); | ||
var matchArray = [], nonGlobalRegex, nonGlobalMatch; | ||
for (var i in globalMatch) { | ||
nonGlobalRegex = new RegExp(regex); | ||
nonGlobalMatch = globalMatch[i].match(nonGlobalRegex); | ||
matchArray.push(nonGlobalMatch[1]); | ||
} | ||
return matchArray; | ||
var globalRegex = new RegExp(regex, 'g'); | ||
var globalMatch = haystack.match(globalRegex); | ||
var matchArray = [], | ||
nonGlobalRegex, nonGlobalMatch; | ||
for (var i in globalMatch) { | ||
nonGlobalRegex = new RegExp(regex); | ||
nonGlobalMatch = globalMatch[i].match(nonGlobalRegex); | ||
matchArray.push(nonGlobalMatch[1]); | ||
} | ||
return matchArray; | ||
} | ||
function generateCSRSubject(options){ | ||
function generateCSRSubject(options) { | ||
@@ -517,19 +536,19 @@ options = options || {}; | ||
var csrData = { | ||
C: options.country || options.C || "", | ||
ST: options.state || options.ST || "", | ||
L: options.locality || options.L || "", | ||
O: options.organization || options.O || "", | ||
OU: options.organizationUnit || options.OU || "", | ||
CN: options.commonName || options.CN || "localhost", | ||
emailAddress: options.emailAddress || "" | ||
C: options.country || options.C || '', | ||
ST: options.state || options.ST || '', | ||
L: options.locality || options.L || '', | ||
O: options.organization || options.O || '', | ||
OU: options.organizationUnit || options.OU || '', | ||
CN: options.commonName || options.CN || 'localhost', | ||
emailAddress: options.emailAddress || '' | ||
}, | ||
csrBuilder = []; | ||
Object.keys(csrData).forEach(function(key){ | ||
if(csrData[key]){ | ||
csrBuilder.push("/" + key + "=" + csrData[key].replace(/[^\w \.\*\-@]+/g, " ").trim()); | ||
Object.keys(csrData).forEach(function(key) { | ||
if (csrData[key]) { | ||
csrBuilder.push('/' + key + '=' + csrData[key].replace(/[^\w \.\*\-@]+/g, ' ').trim()); | ||
} | ||
}); | ||
return csrBuilder.join(""); | ||
return csrBuilder.join(''); | ||
} | ||
@@ -547,11 +566,11 @@ | ||
var openssl = spawn(pathBin, params), | ||
stdout = "", | ||
stderr = ""; | ||
stdout = '', | ||
stderr = ''; | ||
openssl.stdout.on('data', function (data) { | ||
stdout += (data || "").toString("binary"); | ||
openssl.stdout.on('data', function(data) { | ||
stdout += (data || '').toString('binary'); | ||
}); | ||
openssl.stderr.on('data', function (data) { | ||
stderr += (data || "").toString("binary"); | ||
openssl.stderr.on('data', function(data) { | ||
stderr += (data || '').toString('binary'); | ||
}); | ||
@@ -562,39 +581,49 @@ | ||
// making this fail periodically. | ||
var needed = 2; // wait for both exit and close. | ||
var needed = 2; // wait for both exit and close. | ||
var code = -1; | ||
var bothDone = function() { | ||
if (code) { | ||
callback(new Error("Invalid openssl exit code: " + code + "\n% openssl " + params.join(" ") + "\n" + stderr), code); | ||
} else { | ||
callback(null, code, stdout, stderr); | ||
var finished = false; | ||
var done = function(err) { | ||
if (finished) { | ||
return; | ||
} | ||
}; | ||
openssl.on('exit', function (ret) { | ||
code = ret; | ||
if (err) { | ||
finished = true; | ||
return callback(err); | ||
} | ||
if (--needed < 1) { | ||
bothDone(); | ||
finished = true; | ||
if (code) { | ||
callback(new Error('Invalid openssl exit code: ' + code + '\n% openssl ' + params.join(' ') + '\n' + stderr), code); | ||
} else { | ||
callback(null, code, stdout, stderr); | ||
} | ||
} | ||
}); | ||
}; | ||
openssl.on('close', function () { | ||
stdout = new Buffer(stdout, "binary").toString("utf-8"); | ||
stderr = new Buffer(stderr, "binary").toString("utf-8"); | ||
openssl.on('error', done); | ||
if (--needed < 1) { | ||
bothDone(); | ||
} | ||
openssl.on('exit', function(ret) { | ||
code = ret; | ||
done(); | ||
}); | ||
openssl.on('close', function() { | ||
stdout = new Buffer(stdout, 'binary').toString('utf-8'); | ||
stderr = new Buffer(stderr, 'binary').toString('utf-8'); | ||
done(); | ||
}); | ||
} | ||
function spawnWrapper(params, tmpfiles, callback){ | ||
function spawnWrapper(params, tmpfiles, callback) { | ||
var files = []; | ||
var toUnlink = []; | ||
if(tmpfiles){ | ||
if (tmpfiles) { | ||
tmpfiles = [].concat(tmpfiles || []); | ||
params.forEach(function(value, i){ | ||
params.forEach(function(value, i) { | ||
var fpath; | ||
if(value == "--TMPFILE--"){ | ||
fpath = pathlib.join(tempDir, crypto.randomBytes(20).toString("hex")); | ||
if (value === '--TMPFILE--') { | ||
fpath = pathlib.join(tempDir, crypto.randomBytes(20).toString('hex')); | ||
files.push({ | ||
@@ -609,10 +638,10 @@ path: fpath, | ||
var processFiles = function(){ | ||
var processFiles = function() { | ||
var file = files.shift(); | ||
if(!file){ | ||
if (!file) { | ||
return spawnSSL(); | ||
} | ||
fs.writeFile(file.path, file.contents, function(){ | ||
fs.writeFile(file.path, file.contents, function() { | ||
toUnlink.push(file.path); | ||
@@ -623,5 +652,5 @@ processFiles(); | ||
var spawnSSL = function(){ | ||
var spawnSSL = function() { | ||
spawnOpenSSL(params, function(err, code, stdout, stderr) { | ||
toUnlink.forEach(function(filePath){ | ||
toUnlink.forEach(function(filePath) { | ||
fs.unlink(filePath); | ||
@@ -640,4 +669,4 @@ }); | ||
*/ | ||
function execOpenSSL(params, searchStr, tmpfiles, callback){ | ||
if(!callback && typeof tmpfiles == "function"){ | ||
function execOpenSSL(params, searchStr, tmpfiles, callback) { | ||
if (!callback && typeof tmpfiles === 'function') { | ||
callback = tmpfiles; | ||
@@ -654,20 +683,20 @@ tmpfiles = false; | ||
if((start = stdout.match(new RegExp("\\-+BEGIN "+searchStr+"\\-+$", "m")))){ | ||
if ((start = stdout.match(new RegExp('\\-+BEGIN ' + searchStr + '\\-+$', 'm')))) { | ||
start = start.index; | ||
}else{ | ||
} else { | ||
start = -1; | ||
} | ||
if((end = stdout.match(new RegExp("^\\-+END "+searchStr+"\\-+", "m")))){ | ||
end = end.index + (end[0] || "").length; | ||
}else{ | ||
if ((end = stdout.match(new RegExp('^\\-+END ' + searchStr + '\\-+', 'm')))) { | ||
end = end.index + (end[0] || '').length; | ||
} else { | ||
end = -1; | ||
} | ||
if(start >= 0 && end >=0){ | ||
if (start >= 0 && end >= 0) { | ||
return callback(null, stdout.substring(start, end)); | ||
}else{ | ||
return callback(new Error(searchStr + " not found from openssl output:\n---stdout---\n" + stdout + "\n---stderr---\n" + stderr + "\ncode: " + code)); | ||
} else { | ||
return callback(new Error(searchStr + ' not found from openssl output:\n---stdout---\n' + stdout + '\n---stderr---\n' + stderr + '\ncode: ' + code)); | ||
} | ||
}); | ||
} | ||
} |
@@ -5,3 +5,3 @@ { | ||
"description": "Create private keys and certificates with node.js", | ||
"version": "1.4.5", | ||
"version": "1.4.6", | ||
"repository": { | ||
@@ -23,2 +23,2 @@ "type": "git", | ||
} | ||
} | ||
} |
@@ -38,7 +38,7 @@ pem | ||
var app = express(); | ||
app.get('/', requireAuth, function(req, res){ | ||
res.send("o hai!"); | ||
}); | ||
https.createServer({key: keys.serviceKey, cert: keys.certificate}, app).listen(443); | ||
@@ -130,3 +130,3 @@ }); | ||
* **callback** is a callback function with an error object and `{country, state, locality, organization, organizationUnit, commonName, emailAddress, validity{start, end}, san{dns, ip}? }` | ||
? *san* is only present if the CSR or certificate has SAN entries. | ||
@@ -158,4 +158,2 @@ | ||
**MIT** | ||
**MIT** |
281
test/pem.js
@@ -1,14 +0,17 @@ | ||
var pem = require(".."), | ||
testCase = require('nodeunit').testCase; | ||
process.env.PEMJS_TMPDIR = "./tmp"; | ||
var fs = require("fs"); | ||
'use strict'; | ||
var pem = require('..'); | ||
var fs = require('fs'); | ||
process.env.PEMJS_TMPDIR = './tmp'; | ||
try { | ||
fs.mkdirSync("./tmp"); | ||
fs.mkdirSync('./tmp'); | ||
} catch (e) {} | ||
exports["General Tests"] = { | ||
exports['General Tests'] = { | ||
"Create default sized Private key": function(test){ | ||
pem.createPrivateKey(function(error, data){ | ||
var key = (data && data.key || "").toString(); | ||
'Create default sized Private key': function(test) { | ||
pem.createPrivateKey(function(error, data) { | ||
var key = (data && data.key || '').toString(); | ||
test.ifError(error); | ||
@@ -19,3 +22,3 @@ test.ok(key); | ||
test.ok(key.trim().length > 850 && key.trim().length < 1900); | ||
test.ok(fs.readdirSync("./tmp").length == 0); | ||
test.ok(fs.readdirSync('./tmp').length === 0); | ||
test.done(); | ||
@@ -25,5 +28,5 @@ }); | ||
"Create 2048bit Private key": function(test){ | ||
pem.createPrivateKey(2048, function(error, data){ | ||
var key = (data && data.key || "").toString(); | ||
'Create 2048bit Private key': function(test) { | ||
pem.createPrivateKey(2048, function(error, data) { | ||
var key = (data && data.key || '').toString(); | ||
test.ifError(error); | ||
@@ -34,3 +37,3 @@ test.ok(key); | ||
test.ok(key.trim().length > 1650 && key.trim().length < 1700); | ||
test.ok(fs.readdirSync("./tmp").length == 0); | ||
test.ok(fs.readdirSync('./tmp').length === 0); | ||
test.done(); | ||
@@ -40,5 +43,5 @@ }); | ||
"Create default CSR": function(test){ | ||
pem.createCSR(function(error, data){ | ||
var csr = (data && data.csr || "").toString(); | ||
'Create default CSR': function(test) { | ||
pem.createCSR(function(error, data) { | ||
var csr = (data && data.csr || '').toString(); | ||
test.ifError(error); | ||
@@ -50,3 +53,3 @@ test.ok(csr); | ||
test.ok(data && data.clientKey); | ||
test.ok(fs.readdirSync("./tmp").length == 0); | ||
test.ok(fs.readdirSync('./tmp').length === 0); | ||
test.done(); | ||
@@ -56,8 +59,10 @@ }); | ||
"Create CSR with own key": function(test){ | ||
pem.createPrivateKey(function(error, data){ | ||
var key = (data && data.key || "").toString(); | ||
'Create CSR with own key': function(test) { | ||
pem.createPrivateKey(function(error, data) { | ||
var key = (data && data.key || '').toString(); | ||
pem.createCSR({clientKey: key}, function(error, data){ | ||
var csr = (data && data.csr || "").toString(); | ||
pem.createCSR({ | ||
clientKey: key | ||
}, function(error, data) { | ||
var csr = (data && data.csr || '').toString(); | ||
test.ifError(error); | ||
@@ -71,12 +76,11 @@ test.ok(csr); | ||
test.ok(data && data.clientKey); | ||
test.ok(fs.readdirSync("./tmp").length == 0); | ||
test.ok(fs.readdirSync('./tmp').length === 0); | ||
test.done(); | ||
}); | ||
}); | ||
}, | ||
"Create default certificate": function(test){ | ||
pem.createCertificate(function(error, data){ | ||
var certificate = (data && data.certificate || "").toString(); | ||
'Create default certificate': function(test) { | ||
pem.createCertificate(function(error, data) { | ||
var certificate = (data && data.certificate || '').toString(); | ||
test.ifError(error); | ||
@@ -87,3 +91,3 @@ test.ok(certificate); | ||
test.ok((data && data.clientKey) != (data && data.serviceKey)); | ||
test.ok((data && data.clientKey) !== (data && data.serviceKey)); | ||
@@ -93,3 +97,3 @@ test.ok(data && data.clientKey); | ||
test.ok(data && data.csr); | ||
test.ok(fs.readdirSync("./tmp").length == 0); | ||
test.ok(fs.readdirSync('./tmp').length === 0); | ||
test.done(); | ||
@@ -99,5 +103,7 @@ }); | ||
"Create self signed certificate": function(test){ | ||
pem.createCertificate({selfSigned: true}, function(error, data){ | ||
var certificate = (data && data.certificate || "").toString(); | ||
'Create self signed certificate': function(test) { | ||
pem.createCertificate({ | ||
selfSigned: true | ||
}, function(error, data) { | ||
var certificate = (data && data.certificate || '').toString(); | ||
test.ifError(error); | ||
@@ -108,3 +114,3 @@ test.ok(certificate); | ||
test.ok((data && data.clientKey) == (data && data.serviceKey)); | ||
test.ok((data && data.clientKey) === (data && data.serviceKey)); | ||
@@ -114,3 +120,3 @@ test.ok(data && data.clientKey); | ||
test.ok(data && data.csr); | ||
test.ok(fs.readdirSync("./tmp").length == 0); | ||
test.ok(fs.readdirSync('./tmp').length === 0); | ||
test.done(); | ||
@@ -120,11 +126,11 @@ }); | ||
"Read default cert data from CSR": function(test){ | ||
pem.createCSR(function(error, data){ | ||
var csr = (data && data.csr || "").toString(); | ||
'Read default cert data from CSR': function(test) { | ||
pem.createCSR(function(error, data) { | ||
var csr = (data && data.csr || '').toString(); | ||
test.ifError(error); | ||
test.ok(fs.readdirSync("./tmp").length == 0); | ||
test.ok(fs.readdirSync('./tmp').length === 0); | ||
pem.readCertificateInfo(csr, function(error, data){ | ||
pem.readCertificateInfo(csr, function(error, data) { | ||
test.ifError(error); | ||
test.deepEqual(data,{ | ||
test.deepEqual(data, { | ||
country: '', | ||
@@ -136,4 +142,5 @@ state: '', | ||
commonName: 'localhost', | ||
emailAddress: '' }); | ||
test.ok(fs.readdirSync("./tmp").length == 0); | ||
emailAddress: '' | ||
}); | ||
test.ok(fs.readdirSync('./tmp').length === 0); | ||
test.done(); | ||
@@ -144,19 +151,21 @@ }); | ||
"Read edited cert data from CSR": function(test){ | ||
var certInfo = {country:"EE", | ||
state:"Harjumaa", | ||
locality:"Tallinn", | ||
organization:"Node.ee", | ||
organizationUnit:"test", | ||
commonName:"www.node.ee", | ||
emailAddress:"andris@node.ee"}; | ||
pem.createCSR(Object.create(certInfo), function(error, data){ | ||
var csr = (data && data.csr || "").toString(); | ||
'Read edited cert data from CSR': function(test) { | ||
var certInfo = { | ||
country: 'EE', | ||
state: 'Harjumaa', | ||
locality: 'Tallinn', | ||
organization: 'Node.ee', | ||
organizationUnit: 'test', | ||
commonName: 'www.node.ee', | ||
emailAddress: 'andris@node.ee' | ||
}; | ||
pem.createCSR(Object.create(certInfo), function(error, data) { | ||
var csr = (data && data.csr || '').toString(); | ||
test.ifError(error); | ||
test.ok(fs.readdirSync("./tmp").length == 0); | ||
test.ok(fs.readdirSync('./tmp').length === 0); | ||
pem.readCertificateInfo(csr, function(error, data){ | ||
pem.readCertificateInfo(csr, function(error, data) { | ||
test.ifError(error); | ||
test.deepEqual(data, certInfo); | ||
test.ok(fs.readdirSync("./tmp").length == 0); | ||
test.ok(fs.readdirSync('./tmp').length === 0); | ||
test.done(); | ||
@@ -167,13 +176,16 @@ }); | ||
"Read default cert data from certificate": function(test){ | ||
pem.createCertificate(function(error, data){ | ||
var certificate = (data && data.certificate || "").toString(); | ||
'Read default cert data from certificate': function(test) { | ||
pem.createCertificate(function(error, data) { | ||
var certificate = (data && data.certificate || '').toString(); | ||
test.ifError(error); | ||
test.ok(fs.readdirSync("./tmp").length == 0); | ||
test.ok(fs.readdirSync('./tmp').length === 0); | ||
pem.readCertificateInfo(certificate, function(error, data){ | ||
pem.readCertificateInfo(certificate, function(error, data) { | ||
test.ifError(error); | ||
if(data.validity) | ||
if (data.validity) { | ||
delete data.validity; | ||
test.deepEqual(data,{ | ||
} | ||
test.deepEqual(data, { | ||
country: '', | ||
@@ -185,4 +197,5 @@ state: '', | ||
commonName: 'localhost', | ||
emailAddress: '' }); | ||
test.ok(fs.readdirSync("./tmp").length == 0); | ||
emailAddress: '' | ||
}); | ||
test.ok(fs.readdirSync('./tmp').length === 0); | ||
test.done(); | ||
@@ -193,21 +206,26 @@ }); | ||
"Read edited cert data from certificate": function(test){ | ||
var certInfo = {country:"EE", | ||
state:"Harjumaa", | ||
locality:"Tallinn", | ||
organization:"Node.ee", | ||
organizationUnit:"test", | ||
commonName:"www.node.ee", | ||
emailAddress:"andris@node.ee"}; | ||
pem.createCertificate(Object.create(certInfo), function(error, data){ | ||
var certificate = (data && data.certificate || "").toString(); | ||
'Read edited cert data from certificate': function(test) { | ||
var certInfo = { | ||
country: 'EE', | ||
state: 'Harjumaa', | ||
locality: 'Tallinn', | ||
organization: 'Node.ee', | ||
organizationUnit: 'test', | ||
commonName: 'www.node.ee', | ||
emailAddress: 'andris@node.ee' | ||
}; | ||
pem.createCertificate(Object.create(certInfo), function(error, data) { | ||
var certificate = (data && data.certificate || '').toString(); | ||
test.ifError(error); | ||
test.ok(fs.readdirSync("./tmp").length == 0); | ||
test.ok(fs.readdirSync('./tmp').length === 0); | ||
pem.readCertificateInfo(certificate, function(error, data){ | ||
pem.readCertificateInfo(certificate, function(error, data) { | ||
test.ifError(error); | ||
if(data.validity) | ||
if (data.validity) { | ||
delete data.validity; | ||
} | ||
test.deepEqual(data, certInfo); | ||
test.ok(fs.readdirSync("./tmp").length == 0); | ||
test.ok(fs.readdirSync('./tmp').length === 0); | ||
test.done(); | ||
@@ -218,11 +236,11 @@ }); | ||
"Get public key from private key": function(test){ | ||
pem.createPrivateKey(function(error, data){ | ||
var key = (data && data.key || "").toString(); | ||
'Get public key from private key': function(test) { | ||
pem.createPrivateKey(function(error, data) { | ||
var key = (data && data.key || '').toString(); | ||
test.ifError(error); | ||
test.ok(key); | ||
test.ok(fs.readdirSync("./tmp").length == 0); | ||
test.ok(fs.readdirSync('./tmp').length === 0); | ||
pem.getPublicKey(key, function(error, data){ | ||
var pubkey = (data && data.publicKey || "").toString(); | ||
pem.getPublicKey(key, function(error, data) { | ||
var pubkey = (data && data.publicKey || '').toString(); | ||
test.ifError(error); | ||
@@ -233,19 +251,18 @@ test.ok(pubkey); | ||
test.ok(pubkey.match(/\n\-\-\-\-\-END PUBLIC KEY\-\-\-\-\-\n*$/)); | ||
test.ok(fs.readdirSync("./tmp").length == 0); | ||
test.ok(fs.readdirSync('./tmp').length === 0); | ||
test.done(); | ||
}); | ||
}); | ||
}, | ||
"Get public key from CSR": function(test){ | ||
pem.createCSR(function(error, data){ | ||
var key = (data && data.clientKey || "").toString(); | ||
'Get public key from CSR': function(test) { | ||
pem.createCSR(function(error, data) { | ||
var key = (data && data.clientKey || '').toString(); | ||
test.ifError(error); | ||
test.ok(key); | ||
test.ok(fs.readdirSync("./tmp").length == 0); | ||
test.ok(fs.readdirSync('./tmp').length === 0); | ||
pem.getPublicKey(key, function(error, data){ | ||
var pubkey = (data && data.publicKey || "").toString(); | ||
pem.getPublicKey(key, function(error, data) { | ||
var pubkey = (data && data.publicKey || '').toString(); | ||
test.ifError(error); | ||
@@ -256,19 +273,18 @@ test.ok(pubkey); | ||
test.ok(pubkey.match(/\n\-\-\-\-\-END PUBLIC KEY\-\-\-\-\-\n*$/)); | ||
test.ok(fs.readdirSync("./tmp").length == 0); | ||
test.ok(fs.readdirSync('./tmp').length === 0); | ||
test.done(); | ||
}); | ||
}); | ||
}, | ||
"Get public key from certificate": function(test){ | ||
pem.createCertificate(function(error, data){ | ||
var key = (data && data.clientKey || "").toString(); | ||
'Get public key from certificate': function(test) { | ||
pem.createCertificate(function(error, data) { | ||
var key = (data && data.clientKey || '').toString(); | ||
test.ifError(error); | ||
test.ok(key); | ||
test.ok(fs.readdirSync("./tmp").length == 0); | ||
test.ok(fs.readdirSync('./tmp').length === 0); | ||
pem.getPublicKey(key, function(error, data){ | ||
var pubkey = (data && data.publicKey || "").toString(); | ||
pem.getPublicKey(key, function(error, data) { | ||
var pubkey = (data && data.publicKey || '').toString(); | ||
test.ifError(error); | ||
@@ -279,69 +295,66 @@ test.ok(pubkey); | ||
test.ok(pubkey.match(/\n\-\-\-\-\-END PUBLIC KEY\-\-\-\-\-\n*$/)); | ||
test.ok(fs.readdirSync("./tmp").length == 0); | ||
test.ok(fs.readdirSync('./tmp').length === 0); | ||
test.done(); | ||
}); | ||
}); | ||
}, | ||
"Get fingerprint from certificate": function(test){ | ||
pem.createCertificate(function(error, data){ | ||
var certificate = (data && data.certificate || "").toString(); | ||
'Get fingerprint from certificate': function(test) { | ||
pem.createCertificate(function(error, data) { | ||
var certificate = (data && data.certificate || '').toString(); | ||
test.ifError(error); | ||
test.ok(certificate); | ||
test.ok(fs.readdirSync("./tmp").length == 0); | ||
test.ok(fs.readdirSync('./tmp').length === 0); | ||
pem.getFingerprint(certificate, function(error, data){ | ||
var fingerprint = (data && data.fingerprint || "").toString(); | ||
pem.getFingerprint(certificate, function(error, data) { | ||
var fingerprint = (data && data.fingerprint || '').toString(); | ||
test.ifError(error); | ||
test.ok(fingerprint); | ||
test.ok(fingerprint.match(/^[0-9A-F]{2}(:[0-9A-F]{2}){19}$/)); | ||
test.ok(fs.readdirSync("./tmp").length == 0); | ||
test.ok(fs.readdirSync('./tmp').length === 0); | ||
test.done(); | ||
}); | ||
}); | ||
}, | ||
"Get modulus from certificate": function(test){ | ||
pem.createCertificate(function(error, data){ | ||
var certificate = (data && data.certificate || "").toString(); | ||
var key = (data && data.clientKey || "").toString(); | ||
'Get modulus from certificate': function(test) { | ||
pem.createCertificate(function(error, data) { | ||
var certificate = (data && data.certificate || '').toString(); | ||
test.ifError(error); | ||
test.ok(certificate); | ||
test.ok(fs.readdirSync("./tmp").length == 0); | ||
test.ok(fs.readdirSync('./tmp').length === 0); | ||
pem.getModulus(certificate, function(error, data){ | ||
var certmodulus = (data && data.modulus || "").toString(); | ||
pem.getModulus(certificate, function(error, data) { | ||
var certmodulus = (data && data.modulus || '').toString(); | ||
test.ifError(error); | ||
test.ok(certmodulus); | ||
test.ok(certmodulus.match(/^[0-9A-F]*$/)); | ||
test.ok(fs.readdirSync("./tmp").length == 0); | ||
pem.getModulus(certificate, function(error, data){ | ||
var keymodulus = (data && data.modulus || "").toString(); | ||
test.ok(fs.readdirSync('./tmp').length === 0); | ||
pem.getModulus(certificate, function(error, data) { | ||
var keymodulus = (data && data.modulus || '').toString(); | ||
test.ifError(error); | ||
test.ok(keymodulus); | ||
test.ok(keymodulus.match(/^[0-9A-F]*$/)); | ||
test.ok(keymodulus == certmodulus); | ||
test.ok(fs.readdirSync("./tmp").length == 0); | ||
test.ok(keymodulus === certmodulus); | ||
test.ok(fs.readdirSync('./tmp').length === 0); | ||
test.done(); | ||
}); | ||
}); | ||
}); | ||
}, | ||
"Create and verify wildcard certificate": function(test) { | ||
var certInfo = {commonName:"*.node.ee"}; | ||
pem.createCertificate(Object.create(certInfo), function(error, data){ | ||
var certificate = (data && data.certificate || "").toString(); | ||
'Create and verify wildcard certificate': function(test) { | ||
var certInfo = { | ||
commonName: '*.node.ee' | ||
}; | ||
pem.createCertificate(Object.create(certInfo), function(error, data) { | ||
var certificate = (data && data.certificate || '').toString(); | ||
test.ifError(error); | ||
test.ok(fs.readdirSync("./tmp").length == 0); | ||
test.ok(fs.readdirSync('./tmp').length === 0); | ||
pem.readCertificateInfo(certificate, function(error, data){ | ||
pem.readCertificateInfo(certificate, function(error, data) { | ||
test.ifError(error); | ||
test.equal(data.commonName, certInfo.commonName); | ||
test.ok(fs.readdirSync("./tmp").length == 0); | ||
test.equal(data.commonName, certInfo.commonName); | ||
test.ok(fs.readdirSync('./tmp').length === 0); | ||
test.done(); | ||
@@ -351,2 +364,2 @@ }); | ||
} | ||
}; | ||
}; |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
Network access
Supply chain riskThis module accesses the network.
Found 1 instance in 1 package
Shell access
Supply chain riskThis module accesses the system shell. Accessing the system shell increases the risk of executing arbitrary code.
Found 1 instance in 1 package
Filesystem access
Supply chain riskAccesses the file system, and could potentially read sensitive data.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
Network access
Supply chain riskThis module accesses the network.
Found 1 instance in 1 package
Shell access
Supply chain riskThis module accesses the system shell. Accessing the system shell increases the risk of executing arbitrary code.
Found 1 instance in 1 package
Filesystem access
Supply chain riskAccesses the file system, and could potentially read sensitive data.
Found 1 instance in 1 package
40042
8
880
156