Skip to content

Commit 3eebfb7

Browse files
committed
crypto: clarify missing cipher error
Explain that a cipher is required when a passphrase is provided. Signed-off-by: Filip Skokan <panva.ip@gmail.com>
1 parent f5df725 commit 3eebfb7

2 files changed

Lines changed: 5 additions & 2 deletions

File tree

lib/internal/crypto/keys.js

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -470,7 +470,9 @@ function parseKeyEncoding(enc, keyType, isPublic, objName) {
470470
encodingNames[type], 'does not support encryption');
471471
}
472472
} else if (passphrase !== undefined) {
473-
throw new ERR_INVALID_ARG_VALUE(option('cipher', objName), cipher);
473+
throw new ERR_INVALID_ARG_VALUE(
474+
option('cipher', objName), cipher,
475+
'is required when a passphrase is specified');
474476
}
475477
}
476478

test/parallel/test-crypto-key-objects.js

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1014,7 +1014,8 @@ if (!process.features.openssl_is_boringssl) {
10141014
}, {
10151015
name: 'TypeError',
10161016
code: 'ERR_INVALID_ARG_VALUE',
1017-
message: "The property 'options.cipher' is invalid. Received undefined"
1017+
message: "The property 'options.cipher' is required when a " +
1018+
'passphrase is specified. Received undefined',
10181019
});
10191020
}
10201021

0 commit comments

Comments
 (0)