Skip to content

Commit

Permalink
crypto: fix crash of encrypted private key export without cipher
Browse files Browse the repository at this point in the history
PR-URL: #27041
Reviewed-By: Ben Noordhuis <info@bnoordhuis.nl>
Reviewed-By: Ruben Bridgewater <ruben@bridgewater.de>
Signed-off-by: Beth Griggs <Bethany.Griggs@uk.ibm.com>
  • Loading branch information
panva authored and BethGriggs committed Apr 9, 2019
1 parent 19a30f3 commit 2b791d8
Showing 1 changed file with 14 additions and 0 deletions.
14 changes: 14 additions & 0 deletions test/parallel/test-crypto-key-objects.js
Original file line number Diff line number Diff line change
Expand Up @@ -181,3 +181,17 @@ const privatePem = fixtures.readSync('test_rsa_privkey.pem', 'ascii');
message: 'The value "undefined" is invalid for option "cipher"'
});
}

{
// Exporting an encrypted private key requires a cipher
const privateKey = createPrivateKey(privatePem);
common.expectsError(() => {
privateKey.export({
format: 'pem', type: 'pkcs8', passphrase: 'super-secret'
});
}, {
type: TypeError,
code: 'ERR_INVALID_OPT_VALUE',
message: 'The value "undefined" is invalid for option "cipher"'
});
}

0 comments on commit 2b791d8

Please sign in to comment.