Skip to content

Commit

Permalink
Fixes caAlias usage
Browse files Browse the repository at this point in the history
Signed-off-by: Ben Rosenblum <[email protected]>
  • Loading branch information
morph166955 committed Jul 10, 2023
1 parent 95fe91d commit dfcdc20
Showing 1 changed file with 4 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -262,7 +262,8 @@ public void loadFromKeyStore(String keystorePassword, byte[] keyString)
byte[] byteKey = keystore.getKey(this.alias, keystorePassword.toCharArray()).getEncoded();
this.privKey = encrypt(new String(Base64.getEncoder().encode(byteKey)), key);
setCert(keystore.getCertificate(this.alias));
Certificate caCert = keystore.getCertificate("trustedCa");
String caAlias = this.caAlias;
Certificate caCert = keystore.getCertificate(caAlias);
if (caCert != null) {
setCaCert(caCert);
}
Expand All @@ -278,7 +279,8 @@ public KeyStore getKeyStore(String keystorePassword, byte[] keyString)
keystore.setKeyEntry(this.alias, kf.generatePrivate(keySpec), keystorePassword.toCharArray(),
new java.security.cert.Certificate[] { getCert() });
if (!caCert.isEmpty()) {
keystore.setCertificateEntry("trustedCa", getCaCert());
String caAlias = this.caAlias;
keystore.setCertificateEntry(caAlias, getCaCert());
}
return keystore;
}
Expand Down

0 comments on commit dfcdc20

Please sign in to comment.