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 Mar 16, 2023
1 parent 7182c47 commit 6977c63
Showing 1 changed file with 4 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -173,9 +173,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 @@ -185,6 +182,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 @@ -196,7 +196,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 6977c63

Please sign in to comment.