Skip to content

Commit 31f8c91

Browse files
panvaaduh95
authored andcommitted
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> PR-URL: #64852 Reviewed-By: James M Snell <jasnell@gmail.com> Reviewed-By: Yagiz Nizipli <yagiz@nizipli.com>
1 parent efa22e7 commit 31f8c91

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
@@ -479,7 +479,9 @@ function parseKeyEncoding(enc, keyType, isPublic, objName) {
479479
encodingNames[type], 'does not support encryption');
480480
}
481481
} else if (passphrase !== undefined) {
482-
throw new ERR_INVALID_ARG_VALUE(option('cipher', objName), cipher);
482+
throw new ERR_INVALID_ARG_VALUE(
483+
option('cipher', objName), cipher,
484+
'is required when a passphrase is specified');
483485
}
484486
}
485487

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)