use of org.bouncycastle.openssl.EncryptionException in project certmgr by hdecarne.
the class PEMCertReaderWriter method convertKey.
private static KeyPair convertKey(PEMEncryptedKeyPair pemObject, String resource, PasswordCallback password) throws IOException {
PEMKeyPair pemKeyPair = null;
Throwable passwordException = null;
while (pemKeyPair == null) {
char[] passwordChars = (passwordException == null ? password.queryPassword(resource) : password.requeryPassword(resource, passwordException));
if (passwordChars == null) {
throw new PasswordRequiredException(resource, passwordException);
}
PEMDecryptorProvider pemDecryptorProvider = PEM_DECRYPTOR_PROVIDER_BUILDER.build(passwordChars);
try {
pemKeyPair = pemObject.decryptKeyPair(pemDecryptorProvider);
} catch (EncryptionException e) {
passwordException = e;
}
}
return convertKey(pemKeyPair);
}
Aggregations