Skip to content

Commit

Permalink
test: fix flaky key pair generation test
Browse files Browse the repository at this point in the history
There is a very small chance (about 0.4%) that OpenSSL will
successfully decrypt a key without the correct passphrase and will
then fail while parsing its ASN.1 structure. In those rare cases,
the error message will be different.

PR-URL: #22980
Fixes: #22978
Reviewed-By: Anna Henningsen <anna@addaleax.net>
Reviewed-By: Rich Trott <rtrott@gmail.com>
  • Loading branch information
tniessen authored and targos committed Sep 21, 2018
1 parent d38ce82 commit 83278b2
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions test/parallel/test-crypto-keygen.js
Original file line number Diff line number Diff line change
Expand Up @@ -169,7 +169,7 @@ function convertDERToPEM(label, der) {
// Since the private key is encrypted, signing shouldn't work anymore.
assert.throws(() => {
testSignVerify(publicKey, privateKey);
}, /bad decrypt/);
}, /bad decrypt|asn1 encoding routines/);

// Signing should work with the correct password.
testSignVerify(publicKey, {
Expand Down Expand Up @@ -232,7 +232,7 @@ function convertDERToPEM(label, der) {
// Since the private key is encrypted, signing shouldn't work anymore.
assert.throws(() => {
testSignVerify(publicKey, privateKey);
}, /bad decrypt/);
}, /bad decrypt|asn1 encoding routines/);

testSignVerify(publicKey, {
key: privateKey,
Expand Down

0 comments on commit 83278b2

Please sign in to comment.