Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

pem

Package Overview
Dependencies
Maintainers
2
Versions
56
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

pem - npm Package Compare versions

Comparing version 1.10.0 to 1.10.1

129

lib/pem.js

@@ -11,2 +11,3 @@ 'use strict';

var pathOpenSSL;
var openSslVersion;
var tempDir = process.env.PEMJS_TMPDIR || osTmpdir();

@@ -62,6 +63,3 @@

var params = ['genrsa',
'-rand',
'/var/log/mail:/var/log/messages'
];
var params = ['genrsa'];
var cipher = ["aes128", "aes192", "aes256", "camellia128", "camellia192", "camellia256", "des", "des3", "idea"];

@@ -443,2 +441,4 @@

'-noout',
'-nameopt',
'RFC2253,sep_multiline,space_eq',
'-text',

@@ -819,4 +819,5 @@ '-in',

spawnWrapper(params, files, function(err, code, stdout) {
spawnWrapper(params, files, function(err, code, stdout, stderr) {
if (err) {
console.log(err, stdout, stderr);
return callback(err);

@@ -834,70 +835,61 @@ }

// slproweb.com Windows openssl binaries output ' = ' rather than '='
certData = certData.replace(/ = /g, '=');
var serial, subject, subject2, extra, tmp, issuer, issuer2, certValues = {issuer:{}};
var serial, subject, tmp, issuer;
var certValues = {issuer:{}};
var validity = {};
var san;
if ((serial = certData.match(/Serial Number:\s*([^\n]*)\n/)) && serial.length > 1) {
if ((serial = certData.match(/\s{8}Serial Number:\n\s{12}([^\n]*)\n\s{4}\b/)) && serial.length > 1) {
certValues.serial = serial[1];
}
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';
if ((subject = certData.match(/\s{8}Subject:\n(\s*((C|L|O|OU|ST|CN|DC|emailAddress)\s=\s[^\n]+\n))*\s{8}\b/)) && subject.length > 1) {
subject = subject[0];
// country
tmp = subject2.match(/\sC=([^\n].*?)[\n]/);
tmp = subject.match(/\sC\s=\s([^\n].*?)[\n]/);
certValues.country = tmp && tmp[1] || '';
// state
tmp = subject2.match(/\sST=([^\n].*?)[\n]/);
tmp = subject.match(/\sST\s=\s([^\n].*?)[\n]/);
certValues.state = tmp && tmp[1] || '';
// locality
tmp = subject2.match(/\sL=([^\n].*?)[\n]/);
tmp = subject.match(/\sL\s=\s([^\n].*?)[\n]/);
certValues.locality = tmp && tmp[1] || '';
// organization
tmp = subject2.matchAll(/\sO=([^\n].*)/g);
certValues.organization = tmp ? tmp.length>1 ? tmp.map(function(x) {return x[1];}) : tmp[0][1] : '';
tmp = subject.matchAll(/\sO\s=\s([^\n].*)/g);
certValues.organization = tmp?(tmp.length>1?tmp.sort(function(t,n){var e=t[1].toUpperCase(),r=n[1].toUpperCase();return r>e?-1:e>r?1:0;}).sort(function(t,n){return t[1].length-n[1].length;}).map(function(t){return t[1];}):tmp[0][1]):"";
// unit
tmp = subject2.match(/\sOU=([^\n].*?)[\n]/);
certValues.organizationUnit = tmp && tmp[1] || '';
tmp = subject.matchAll(/\sOU\s=\s([^\n].*)/g);
certValues.organizationUnit = tmp?(tmp.length>1?tmp.sort(function(t,n){var e=t[1].toUpperCase(),r=n[1].toUpperCase();return r>e?-1:e>r?1:0;}).sort(function(t,n){return t[1].length-n[1].length;}).map(function(t){return t[1];}):tmp[0][1]):"";
// common name
tmp = subject2.match(/\sCN=([^\n].*?)[\n]/);
certValues.commonName = tmp && tmp[1] || '';
tmp = subject.matchAll(/\sCN\s=\s([^\n].*)/g);
certValues.commonName = tmp?(tmp.length>1?tmp.sort(function(t,n){var e=t[1].toUpperCase(),r=n[1].toUpperCase();return r>e?-1:e>r?1:0;}).sort(function(t,n){return t[1].length-n[1].length;}).map(function(t){return t[1];}):tmp[0][1]):"";
//email
tmp = extra.match(/emailAddress=([^\n\/].*?)[\n\/]/);
certValues.emailAddress = tmp && tmp[1] || '';
tmp = subject.matchAll(/emailAddress\s=\s([^\n].*)/g);
certValues.emailAddress = tmp?(tmp.length>1?tmp.sort(function(t,n){var e=t[1].toUpperCase(),r=n[1].toUpperCase();return r>e?-1:e>r?1:0;}).sort(function(t,n){return t[1].length-n[1].length;}).map(function(t){return t[1];}):tmp[0][1]):"";
// DC name
tmp = subject2.match(/\sDC=([^\n].*?)[\n]/);
certValues.dc = tmp && tmp[1] || '';
tmp = subject.matchAll(/\sDC\s=\s([^\n].*)/g);
certValues.dc = tmp?(tmp.length>1?tmp.sort(function(t,n){var e=t[1].toUpperCase(),r=n[1].toUpperCase();return r>e?-1:e>r?1:0;}).sort(function(t,n){return t[1].length-n[1].length;}).map(function(t){return t[1];}):tmp[0][1]):"";
}
if ((issuer = certData.match(/Issuer:([^\n]*)\n/)) && issuer.length > 1) {
issuer2 = linebrakes(issuer[1] + '\n');
issuer = issuer[1];
if ((issuer = certData.match(/\s{8}Issuer:\n(\s{12}(C|L|O|OU|ST|CN|DC|emailAddress)\s=\s[^\n\r].*\n)*\s{8}\b/)) && issuer.length > 1) {
issuer = issuer[0];
// country
tmp = issuer2.match(/\sC=([^\n].*?)[\n]/);
tmp = issuer.match(/\sC\s=\s([^\n].*?)[\n]/);
certValues.issuer.country = tmp && tmp[1] || '';
// state
tmp = issuer2.match(/\sST=([^\n].*?)[\n]/);
tmp = issuer.match(/\sST\s=\s([^\n].*?)[\n]/);
certValues.issuer.state = tmp && tmp[1] || '';
// locality
tmp = issuer2.match(/\sL=([^\n].*?)[\n]/);
tmp = issuer.match(/\sL\s=\s([^\n].*?)[\n]/);
certValues.issuer.locality = tmp && tmp[1] || '';
// organization
tmp = issuer2.match(/\sO=([^\n].*?)[\n]/);
certValues.issuer.organization = tmp && tmp[1] || '';
tmp = issuer.matchAll(/\sO\s=\s([^\n].*)/g);
certValues.issuer.organization = tmp?(tmp.length>1?tmp.sort(function(t,n){var e=t[1].toUpperCase(),r=n[1].toUpperCase();return r>e?-1:e>r?1:0;}).sort(function(t,n){return t[1].length-n[1].length;}).map(function(t){return t[1];}):tmp[0][1]):"";
// unit
tmp = issuer2.match(/\sOU=([^\n].*?)[\n]/);
certValues.issuer.organizationUnit = tmp && tmp[1] || '';
tmp = issuer.matchAll(/\sOU\s=\s([^\n].*)/g);
certValues.issuer.organizationUnit = tmp?(tmp.length>1?tmp.sort(function(t,n){var e=t[1].toUpperCase(),r=n[1].toUpperCase();return r>e?-1:e>r?1:0;}).sort(function(t,n){return t[1].length-n[1].length;}).map(function(t){return t[1];}):tmp[0][1]):"";
// common name
tmp = issuer2.match(/\sCN=([^\n].*?)[\n]/);
certValues.issuer.commonName = tmp && tmp[1] || '';
// DC
tmp = issuer2.match(/\sDC=([^\n].*?)[\n]/);
certValues.issuer.dc = tmp && tmp[1] || '';
tmp = issuer.matchAll(/\sCN\s=\s([^\n].*)/g);
certValues.issuer.commonName = tmp?(tmp.length>1?tmp.sort(function(t,n){var e=t[1].toUpperCase(),r=n[1].toUpperCase();return r>e?-1:e>r?1:0;}).sort(function(t,n){return t[1].length-n[1].length;}).map(function(t){return t[1];}):tmp[0][1]):"";
// DC name
tmp = issuer.matchAll(/\sDC\s=\s([^\n].*)/g);
certValues.issuer.dc = tmp?(tmp.length>1?tmp.sort(function(t,n){var e=t[1].toUpperCase(),r=n[1].toUpperCase();return r>e?-1:e>r?1:0;}).sort(function(t,n){return t[1].length-n[1].length;}).map(function(t){return t[1];}):tmp[0][1]):"";
}

@@ -955,29 +947,2 @@

function linebrakes(content) {
var helper_x, subject, type;
helper_x = content.replace(/(C|L|O|OU|ST|CN|DC)=/g, '\n$1=');
helper_x = preg_match_all('((C|L|O|OU|ST|CN|DC)=[^\n].*)', helper_x);
for (var p=0; p<helper_x.length; p++) {
subject = helper_x[p].trim();
type = subject.split('=');
if(type[1].substring(0, 4) !== 'http'){
content = subject.split('/');
}else{
content = [];
content.push(subject);
}
subject = content.shift();
helper_x[p] = rtrim(subject, ',');
}
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, '');
}
function preg_match_all(regex, haystack) {

@@ -1108,5 +1073,8 @@ var globalRegex = new RegExp(regex, 'g');

if (code) {
callback(new Error('Invalid openssl exit code: ' + code + '\n% openssl ' + params.join(' ') + '\n' + stderr), code);
if (code === 2 && openSslVersion === "LIBRESSL") {
return callback(null, code, stdout, stderr);
}
return callback(new Error('Invalid openssl exit code: ' + code + '\n% openssl ' + params.join(' ') + '\n' + stderr), code);
} else {
callback(null, code, stdout, stderr);
return callback(null, code, stdout, stderr);
}

@@ -1233,1 +1201,10 @@ }

}
spawnOpenSSL(['version'], false, function(err, code, stdout, stderr) {
var text = String(stdout) + String(stderr);
var tmp = text.match(/^LibreSSL/i);
openSslVersion = tmp && tmp[0] ? "LibreSSL" : "openssl";
openSslVersion = openSslVersion.toUpperCase();
});

@@ -12,3 +12,3 @@ {

"description": "Create private keys and certificates with node.js and io.js",
"version": "1.10.0",
"version": "1.10.1",
"repository": {

@@ -15,0 +15,0 @@ "type": "git",

@@ -6,3 +6,2 @@ 'use strict';

process.env.PEMJS_TMPDIR = './tmp';

@@ -137,3 +136,3 @@

locality: 'Tallinn',
organization: ['Node.ee', 'Node2.ee'],
organization: ['Node2.ee', 'Node.ee'],
organizationUnit: 'test',

@@ -140,0 +139,0 @@ commonName: 'www.node.ee',

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc