diff options
author | Sam Roberts <vieuxtech@gmail.com> | 2016-12-15 12:47:36 -0800 |
---|---|---|
committer | Sam Roberts <vieuxtech@gmail.com> | 2016-12-19 13:42:56 -0800 |
commit | 0b443845616437d0ccf7ce6ee10c79e1432bc3d7 (patch) | |
tree | e813250917fc0af26b9315c9b702e8129cbc0c5d /lib/_tls_common.js | |
parent | 793d8719ebcb67e2758ba7fd6c50ff864d552716 (diff) | |
download | android-node-v8-0b443845616437d0ccf7ce6ee10c79e1432bc3d7.tar.gz android-node-v8-0b443845616437d0ccf7ce6ee10c79e1432bc3d7.tar.bz2 android-node-v8-0b443845616437d0ccf7ce6ee10c79e1432bc3d7.zip |
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 <fedor.indutny@gmail.com>
Reviewed-By: Ben Noordhuis <info@bnoordhuis.nl>
Diffstat (limited to 'lib/_tls_common.js')
-rw-r--r-- | lib/_tls_common.js | 12 |
1 files changed, 3 insertions, 9 deletions
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); } } |