Skip to content

Commit defc7ee

Browse files
committed
Fix KeyVaultKey so that it does not attempt to load the RSA private key.
1 parent 82c25fa commit defc7ee

File tree

1 file changed

+5
-3
lines changed
  • services/keyvault/azure-keyvault-extensions/src/main/java/com/microsoft/azure/keyvault/extensions

1 file changed

+5
-3
lines changed

services/keyvault/azure-keyvault-extensions/src/main/java/com/microsoft/azure/keyvault/extensions/KeyVaultKey.java

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -81,13 +81,15 @@ protected KeyVaultKey(KeyVaultClient client, KeyBundle keyBundle) {
8181
}
8282

8383
if (key.getKty().equals(JsonWebKeyType.RSA)) {
84-
_implementation = new RsaKey(keyBundle.getKey());
84+
// The private key is not available for KeyVault keys
85+
_implementation = new RsaKey(key.getKid(), key.toRSA(false));
8586
} else if (key.getKty().equals(JsonWebKeyType.RSAHSM)) {
86-
_implementation = new RsaKey(keyBundle.getKey());
87+
// The private key is not available for KeyVault keys
88+
_implementation = new RsaKey(key.getKid(), key.toRSA(false));
8789
}
8890

8991
if (_implementation == null) {
90-
throw new IllegalArgumentException(String.format("The key type %s is not supported", keyBundle.getKey().getKty()));
92+
throw new IllegalArgumentException(String.format("The key type %s is not supported", key.getKty()));
9193
}
9294

9395
_client = client;

0 commit comments

Comments
 (0)