Skip to content

Commit

Permalink
Fix truststore REST Client config when password is not set
Browse files Browse the repository at this point in the history
  • Loading branch information
Sgitario committed Mar 16, 2023
1 parent 0a503ff commit 4502d6a
Showing 1 changed file with 4 additions and 4 deletions.
Expand Up @@ -190,9 +190,6 @@ public ClientBuilder clientLogger(ClientLogger clientLogger) {

@Override
public ClientImpl build() {
Buffer keyStore = asBuffer(this.keyStore, keystorePassword);
Buffer trustStore = asBuffer(this.trustStore, this.trustStorePassword);

HttpClientOptions options = Optional.ofNullable(configuration.getFromContext(HttpClientOptions.class))
.orElseGet(HttpClientOptions::new);
if (http2) {
Expand All @@ -210,6 +207,9 @@ public ClientImpl build() {
options.setVerifyHost(false);
}

char[] effectiveTrustStorePassword = trustStorePassword == null ? EMPTY_CHAR_ARARAY : trustStorePassword;
Buffer keyStore = asBuffer(this.keyStore, keystorePassword);
Buffer trustStore = asBuffer(this.trustStore, effectiveTrustStorePassword);
if (keyStore != null || trustStore != null) {
options = options.setSsl(true);
if (keyStore != null) {
Expand All @@ -221,7 +221,7 @@ public ClientImpl build() {
if (trustStore != null) {
JksOptions jks = new JksOptions();
jks.setValue(trustStore);
jks.setPassword(trustStorePassword == null ? "" : new String(trustStorePassword));
jks.setPassword(new String(effectiveTrustStorePassword));
options.setTrustStoreOptions(jks);
}
}
Expand Down

0 comments on commit 4502d6a

Please sign in to comment.