Skip to content

Commit 61c40f4

Browse files
committed
added UnrecoverableKeyException bad key decryption on PKCS12 KeyStore - relates to github #2082
1 parent 18b8192 commit 61c40f4

File tree

1 file changed

+5
-1
lines changed

1 file changed

+5
-1
lines changed

prov/src/main/java/org/bouncycastle/jcajce/provider/keystore/pkcs12/PKCS12KeyStoreSpi.java

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -672,9 +672,13 @@ else if (algorithm.equals(PKCSObjectIdentifiers.id_PBES2))
672672
return (PrivateKey)cipher.unwrap(data, "", Cipher.PRIVATE_KEY);
673673
}
674674
}
675+
catch (InvalidKeyException e)
676+
{
677+
throw Exceptions.ioException("exception unwrapping private key:" + e.getMessage(), new UnrecoverableKeyException(e.toString()));
678+
}
675679
catch (Exception e)
676680
{
677-
throw new IOException("exception unwrapping private key - " + e.toString());
681+
throw Exceptions.ioException("exception unwrapping private key: " + e.getMessage(), e);
678682
}
679683

680684
throw new IOException("exception unwrapping private key - cannot recognise: " + algorithm);

0 commit comments

Comments
 (0)