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
Relates quarkusio#27925 (comment)

(cherry picked from commit 4502d6a)
  • Loading branch information
Sgitario authored and gsmet committed May 9, 2023
1 parent 8aca9b5 commit ba522d5
Showing 1 changed file with 4 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -172,9 +172,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);

Expand All @@ -183,6 +180,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 @@ -194,7 +194,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 ba522d5

Please sign in to comment.