Skip to content

Commit bd3f2e1

Browse files
henrykuijpersiamharish
authored andcommitted
Fixing BoxDeveloperEditionAPIConnection - decryptPrivateKey() - PEMParser returns PrivateKeyInfo already - Invalid cast #470 (#471)
* Fixing BoxDeveloperEditionAPIConnection - decryptPrivateKey() - PEMParser returns PrivateKeyInfo already - Invalid cast #470 * Adding space after 'cast'
1 parent 21eef7b commit bd3f2e1

File tree

1 file changed

+4
-1
lines changed

1 file changed

+4
-1
lines changed

src/main/java/com/box/sdk/BoxDeveloperEditionAPIConnection.java

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -444,7 +444,10 @@ private PrivateKey decryptPrivateKey() {
444444
Object keyPair = keyReader.readObject();
445445
keyReader.close();
446446

447-
if (keyPair instanceof PEMEncryptedKeyPair) {
447+
if (keyPair instanceof PrivateKeyInfo) {
448+
PrivateKeyInfo keyInfo = (PrivateKeyInfo) keyPair;
449+
decryptedPrivateKey = (new JcaPEMKeyConverter()).getPrivateKey(keyInfo);
450+
} else if (keyPair instanceof PEMEncryptedKeyPair) {
448451
JcePEMDecryptorProviderBuilder builder = new JcePEMDecryptorProviderBuilder();
449452
PEMDecryptorProvider decryptionProvider = builder.build(this.privateKeyPassword.toCharArray());
450453
keyPair = ((PEMEncryptedKeyPair) keyPair).decryptKeyPair(decryptionProvider);

0 commit comments

Comments
 (0)