Skip to content

Commit 2b791d8

Browse files
panvaBethGriggs
authored andcommitted
crypto: fix crash of encrypted private key export without cipher
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>
1 parent 19a30f3 commit 2b791d8

File tree

1 file changed

+14
-0
lines changed

1 file changed

+14
-0
lines changed

test/parallel/test-crypto-key-objects.js

+14
Original file line numberDiff line numberDiff line change
@@ -181,3 +181,17 @@ const privatePem = fixtures.readSync('test_rsa_privkey.pem', 'ascii');
181181
message: 'The value "undefined" is invalid for option "cipher"'
182182
});
183183
}
184+
185+
{
186+
// Exporting an encrypted private key requires a cipher
187+
const privateKey = createPrivateKey(privatePem);
188+
common.expectsError(() => {
189+
privateKey.export({
190+
format: 'pem', type: 'pkcs8', passphrase: 'super-secret'
191+
});
192+
}, {
193+
type: TypeError,
194+
code: 'ERR_INVALID_OPT_VALUE',
195+
message: 'The value "undefined" is invalid for option "cipher"'
196+
});
197+
}

0 commit comments

Comments
 (0)