forge icon indicating copy to clipboard operation
forge copied to clipboard

The `pki.decryptRsaPrivateKey` function can return null if the password is wrong

Open CMCDragonkai opened this issue 4 years ago • 2 comments

The types for pki.decryptRsaPrivateKey indicates that it will always return a rsa.PrivateKey. However if the password is wrong, it will sometimes throw an error, and sometimes return a null.

The null is not indicated by the type signature at all. This threw off me quite a bit, because this is random behaviour as it depends on the generated key as well. The exact exception being thrown is also random.

CMCDragonkai avatar Mar 27 '21 06:03 CMCDragonkai

This tripped me up, too

khoek avatar Jan 17 '22 20:01 khoek

I agree, has the same problem. My password contains "$" sign... and result is null. This problem need to be fixed.

denirun avatar Feb 19 '23 22:02 denirun