NullPointerException when key is not available in the database (#25395)
* NullPointerException when key is not available in the database Closes #24485 Signed-off-by: Douglas Palmer <dpalmer@redhat.com> Co-authored-by: Alexander Schwartz <alexander.schwartz@gmx.net> Co-authored-by: Thomas Darimont <thomas.darimont@googlemail.com>
This commit is contained in:
parent
67d8a7ff9c
commit
4b11afa87b
2 changed files with 6 additions and 0 deletions
|
@ -88,6 +88,9 @@ public class KeystoreUtil {
|
|||
throw new RuntimeException("Couldn't load key with alias '" + keyAlias + "' from keystore");
|
||||
}
|
||||
PublicKey publicKey = keyStore.getCertificate(keyAlias).getPublicKey();
|
||||
if (publicKey == null) {
|
||||
throw new RuntimeException("Couldn't load public key with alias '" + keyAlias + "' from keystore");
|
||||
}
|
||||
return new KeyPair(publicKey, privateKey);
|
||||
} catch (Exception e) {
|
||||
throw new RuntimeException("Failed to load private key: " + e.getMessage(), e);
|
||||
|
|
|
@ -44,6 +44,9 @@ public class ImportedRsaKeyProvider extends AbstractRsaKeyProvider {
|
|||
String certificatePem = model.getConfig().getFirst(Attributes.CERTIFICATE_KEY);
|
||||
|
||||
PrivateKey privateKey = PemUtils.decodePrivateKey(privateRsaKeyPem);
|
||||
if (privateKey == null) {
|
||||
throw new RuntimeException("Key not found on the server. Check key for " + ImportedRsaKeyProviderFactory.ID + " in realm " + realm.getName());
|
||||
}
|
||||
PublicKey publicKey = KeyUtils.extractPublicKey(privateKey);
|
||||
|
||||
KeyPair keyPair = new KeyPair(publicKey, privateKey);
|
||||
|
|
Loading…
Reference in a new issue