From 224822821af526984a4ff8bcab7220d97fbb34b0 Mon Sep 17 00:00:00 2001 From: Praveen Vangeepuram Date: Wed, 13 Feb 2019 13:13:58 -0500 Subject: [PATCH] Fix the issue with generating certificate with serviceKeyPassword --- lib/pem.js | 4 ++-- test/pem.spec.js | 12 ++++++++++++ 2 files changed, 14 insertions(+), 2 deletions(-) diff --git a/lib/pem.js b/lib/pem.js index 503fd647..d11cd0c0 100644 --- a/lib/pem.js +++ b/lib/pem.js @@ -395,7 +395,7 @@ function createCertificate (options, callback) { } } if (options.serviceKeyPassword) { - helper.createPasswordFile({ 'cipher': '', 'password': options.serviceKeyPassword, 'passType': 'in' }, params, delTempPWFiles[delTempPWFiles.length]) + helper.createPasswordFile({ 'cipher': '', 'password': options.serviceKeyPassword, 'passType': 'in' }, params, delTempPWFiles) } tmpfiles.push(options.serviceCertificate) tmpfiles.push(options.serviceKey) @@ -403,7 +403,7 @@ function createCertificate (options, callback) { params.push('-signkey') params.push('--TMPFILE--') if (options.serviceKeyPassword) { - helper.createPasswordFile({ 'cipher': '', 'password': options.serviceKeyPassword, 'passType': 'in' }, params, delTempPWFiles[delTempPWFiles.length]) + helper.createPasswordFile({ 'cipher': '', 'password': options.serviceKeyPassword, 'passType': 'in' }, params, delTempPWFiles) } tmpfiles.push(options.serviceKey) } diff --git a/test/pem.spec.js b/test/pem.spec.js index ac72b0f5..c2b65a74 100644 --- a/test/pem.spec.js +++ b/test/pem.spec.js @@ -195,6 +195,18 @@ describe('General Tests', function () { }) }) + it('create cert using serviceKeyPassword', function (done) { + pem.createCertificate({ + serviceKeyPassword: 'min4chars', + selfSigned: true + }, function (error, data) { + hlp.checkError(error) + hlp.checkCertificate(data, true) + hlp.checkTmpEmpty() + done() + }) + }) + it('create cert using pkey w/ password; create pkcs12', function (done) { pem.createCertificate({ clientKey: pwkey.key,