Skip to content

Commit

Permalink
Start expanding supported keystore / truststore types in REST Client
Browse files Browse the repository at this point in the history
Relates to: quarkusio#38811
  • Loading branch information
geoand committed Feb 16, 2024
1 parent e97f3e2 commit 05e2c61
Showing 1 changed file with 30 additions and 8 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,7 @@
import io.vertx.core.http.HttpClientOptions;
import io.vertx.core.http.HttpVersion;
import io.vertx.core.net.JksOptions;
import io.vertx.core.net.PfxOptions;
import io.vertx.core.net.ProxyOptions;

public class ClientBuilderImpl extends ClientBuilder {
Expand Down Expand Up @@ -227,16 +228,37 @@ public ClientImpl build() {
if (keyStore != null || trustStore != null) {
options = options.setSsl(true);
if (keyStore != null) {
JksOptions jks = new JksOptions();
jks.setValue(keyStore);
jks.setPassword(new String(keystorePassword));
options = options.setKeyStoreOptions(jks);
String keyStoreType = this.keyStore.getType();
if ("PKCS12".equals(keyStoreType)) {
PfxOptions pks = new PfxOptions();
pks.setValue(keyStore);
pks.setPassword(new String(keystorePassword));
options = options.setKeyCertOptions(pks);
} else if ("JKS".equals(keyStoreType)) {
JksOptions jks = new JksOptions();
jks.setValue(keyStore);
jks.setPassword(new String(keystorePassword));
options = options.setKeyCertOptions(jks);
} else {
throw new IllegalStateException("Unsupported key store type " + keyStoreType);
}

}
if (trustStore != null) {
JksOptions jks = new JksOptions();
jks.setValue(trustStore);
jks.setPassword(new String(effectiveTrustStorePassword));
options.setTrustStoreOptions(jks);
String trustStoreType = this.keyStore.getType();
if ("PKCS12".equals(trustStoreType)) {
PfxOptions pks = new PfxOptions();
pks.setValue(trustStore);
pks.setPassword(new String(effectiveTrustStorePassword));
} else if ("JKS".equals(trustStoreType)) {
JksOptions jks = new JksOptions();
jks.setValue(trustStore);
jks.setPassword(new String(effectiveTrustStorePassword));
options.setTrustOptions(jks);
} else {
throw new IllegalStateException("Unsupported key store type " + trustStoreType);
}

}
}

Expand Down

0 comments on commit 05e2c61

Please sign in to comment.