diff --git a/lib/internal/crypto/keys.js b/lib/internal/crypto/keys.js index 250f99cfd20..4efc5a0d4e3 100644 --- a/lib/internal/crypto/keys.js +++ b/lib/internal/crypto/keys.js @@ -470,7 +470,9 @@ function parseKeyEncoding(enc, keyType, isPublic, objName) { encodingNames[type], 'does not support encryption'); } } else if (passphrase !== undefined) { - throw new ERR_INVALID_ARG_VALUE(option('cipher', objName), cipher); + throw new ERR_INVALID_ARG_VALUE( + option('cipher', objName), cipher, + 'is required when a passphrase is specified'); } } diff --git a/test/parallel/test-crypto-key-objects.js b/test/parallel/test-crypto-key-objects.js index 775b752ac3b..dadeb780cf6 100644 --- a/test/parallel/test-crypto-key-objects.js +++ b/test/parallel/test-crypto-key-objects.js @@ -1014,7 +1014,8 @@ if (!process.features.openssl_is_boringssl) { }, { name: 'TypeError', code: 'ERR_INVALID_ARG_VALUE', - message: "The property 'options.cipher' is invalid. Received undefined" + message: "The property 'options.cipher' is required when a " + + 'passphrase is specified. Received undefined', }); }