From 0b443845616437d0ccf7ce6ee10c79e1432bc3d7 Mon Sep 17 00:00:00 2001 From: Sam Roberts Date: Thu, 15 Dec 2016 12:47:36 -0800 Subject: tls: allow obvious key/passphrase combinations Passphrase is now used whether keys are provided singly, in an array of string/buffer, or an array of object, where it used to be ignored in some argument combinations. Specifically, these now work as expected: key: [encryptedPem], passphrase: 'passphrase' and key: [{pem: encryptedPem}] passphrase: 'passphrase' and key: [{pem: unencryptedPem}] PR-URL: https://github.com/nodejs/node/pull/10294 Reviewed-By: Fedor Indutny Reviewed-By: Ben Noordhuis --- lib/_tls_common.js | 12 +++--------- 1 file changed, 3 insertions(+), 9 deletions(-) (limited to 'lib/_tls_common.js') diff --git a/lib/_tls_common.js b/lib/_tls_common.js index 9cb7045386..85ae71f8d1 100644 --- a/lib/_tls_common.js +++ b/lib/_tls_common.js @@ -78,17 +78,11 @@ exports.createSecureContext = function createSecureContext(options, context) { if (Array.isArray(options.key)) { for (i = 0; i < options.key.length; i++) { const key = options.key[i]; - if (key.passphrase) - c.context.setKey(key.pem, key.passphrase); - else - c.context.setKey(key); + const passphrase = key.passphrase || options.passphrase; + c.context.setKey(key.pem || key, passphrase); } } else { - if (options.passphrase) { - c.context.setKey(options.key, options.passphrase); - } else { - c.context.setKey(options.key); - } + c.context.setKey(options.key, options.passphrase); } } -- cgit v1.2.3