Skip to content

Commit

Permalink
* Change variable name
Browse files Browse the repository at this point in the history
* Bump version to 1.7.1
  • Loading branch information
Josef Fröhle committed Feb 27, 2015
1 parent e99e6d6 commit e2edba6
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 9 deletions.
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -16,3 +16,4 @@ npm-debug.log
.DS_Store
tmp
.idea
.npmrc
13 changes: 6 additions & 7 deletions lib/pem.js
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ module.exports.config = config;
* @param {Function} callback Callback function with an error object and {key}
*/
function createPrivateKey(keyBitsize, options, callback) {
var fpath;
var clientKeyPassword;
if (!callback && !options && typeof keyBitsize === 'function') {
callback = keyBitsize;
keyBitsize = undefined;
Expand All @@ -50,18 +50,18 @@ function createPrivateKey(keyBitsize, options, callback) {
var cipher = ["aes128", "aes192", "aes256", "camellia128", "camellia192", "camellia256", "des", "des3", "idea"];

if (options && options.cipher && ( -1 !== Number(cipher.indexOf(options.cipher)) ) && options.password){
fpath = pathlib.join(tempDir, crypto.randomBytes(20).toString('hex'));
fs.writeFileSync(fpath, options.password);
clientKeyPassword = pathlib.join(tempDir, crypto.randomBytes(20).toString('hex'));
fs.writeFileSync(clientKeyPassword, options.password);
params.push( '-' + options.cipher );
params.push( '-passout' );
params.push( 'file:' + fpath );
params.push( 'file:' + clientKeyPassword );
}

params.push(keyBitsize);

execOpenSSL(params, 'RSA PRIVATE KEY', function(error, key) {
if(fpath) {
fs.unlink(fpath);
if(clientKeyPassword) {
fs.unlink(clientKeyPassword);
}
if (error) {
return callback(error);
Expand Down Expand Up @@ -198,7 +198,6 @@ function createCSR(options, callback) {
if (passwordFilePath) {
fs.unlink(passwordFilePath);
}

if (error) {
return callback(error);
}
Expand Down
8 changes: 6 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
@@ -1,8 +1,12 @@
{
"author": "Andris Reinman <andris@kreata.ee>",
"contributors": [{
"name": "Josef Fröhle",
"email": "git@josef-froehle.de"
}],
"name": "pem",
"description": "Create private keys and certificates with node.js",
"version": "1.7.0",
"description": "Create private keys and certificates with node.js and io.js",
"version": "1.7.1",
"repository": {
"type": "git",
"url": "git://github.com/andris9/pem.git"
Expand Down

0 comments on commit e2edba6

Please sign in to comment.