Skip to content

Commit fea0666

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 Backport-PR-URL: #65087 Reviewed-By: James M Snell <jasnell@gmail.com> Reviewed-By: Yagiz Nizipli <yagiz@nizipli.com> Reviewed-By: Antoine du Hamel <duhamelantoine1995@gmail.com>
1 parent 33fec91 commit fea0666

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
@@ -1025,7 +1025,8 @@ if (!process.features.openssl_is_boringssl) {
10251025
}, {
10261026
name: 'TypeError',
10271027
code: 'ERR_INVALID_ARG_VALUE',
1028-
message: "The property 'options.cipher' is invalid. Received undefined"
1028+
message: "The property 'options.cipher' is required when a " +
1029+
'passphrase is specified. Received undefined',
10291030
});
10301031
}
10311032

0 commit comments

Comments
 (0)