Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Remove the usage of lambdas in the TLS registry code #40985

Merged
merged 1 commit into from
Jun 5, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -138,7 +138,12 @@ public void register(String name, TlsConfiguration configuration) {
}

public Supplier<TlsConfigurationRegistry> getSupplier() {
return () -> this;
return new Supplier<TlsConfigurationRegistry>() {
@Override
public TlsConfigurationRegistry get() {
return CertificateRecorder.this;
}
};
}

public void register(String name, Supplier<TlsConfiguration> supplier) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,6 @@
import javax.net.ssl.TrustManagerFactory;

import io.quarkus.tls.TlsConfiguration;
import io.quarkus.tls.runtime.config.KeyStoreConfig;
import io.quarkus.tls.runtime.config.TlsBucketConfig;
import io.quarkus.tls.runtime.config.TlsConfigUtils;
import io.vertx.core.Vertx;
Expand Down Expand Up @@ -138,7 +137,10 @@ public Optional<String> getHostnameVerificationAlgorithm() {

@Override
public boolean usesSni() {
return config.keyStore().map(KeyStoreConfig::sni).orElse(false);
if (config.keyStore().isPresent()) {
return config.keyStore().get().sni();
}
return false;
}

@Override
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,9 @@ private static JksOptions toOptions(JKSKeyStoreConfig config,
+ "' - the key store password is not set and cannot be retrieved from the credential provider.");
}
options.setPassword(p);
config.alias().ifPresent(options::setAlias);
if (config.alias().isPresent()) {
options.setAlias(config.alias().get());
}
String ap = CredentialProviders.getAliasPassword(config.aliasPassword(), keyStoreCredentialProviderConfig)
.orElse(null);
options.setAliasPassword(ap);
Expand All @@ -83,7 +85,9 @@ private static JksOptions toOptions(JKSTrustStoreConfig config,
+ "' - the trust store password is not set and cannot be retrieved from the credential provider.");
}
options.setPassword(password);
config.alias().ifPresent(options::setAlias);
if (config.alias().isPresent()) {
options.setAlias(config.alias().get());
}
} catch (UncheckedIOException e) {
throw new IllegalStateException("Invalid JKS trust store configuration for certificate '" + name
+ "' - cannot read the trust store file '" + config.path() + "'", e);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,9 @@ private static PfxOptions toOptions(P12KeyStoreConfig config, KeyStoreCredential
+ "' - the key store password is not set and cannot be retrieved from the credential provider.");
}
options.setPassword(password);
config.alias().ifPresent(options::setAlias);
if (config.alias().isPresent()) {
options.setAlias(config.alias().get());
}
String ap = CredentialProviders.getAliasPassword(config.aliasPassword(), pc).orElse(null);
options.setAliasPassword(ap);
} catch (UncheckedIOException e) {
Expand All @@ -80,7 +82,9 @@ private static PfxOptions toOptions(P12TrustStoreConfig config, TrustStoreCreden
+ "' - the trust store password is not set and cannot be retrieved from the credential provider.");
}
options.setPassword(password);
config.alias().ifPresent(options::setAlias);
if (config.alias().isPresent()) {
options.setAlias(config.alias().get());
}
} catch (UncheckedIOException e) {
throw new IllegalStateException("Invalid P12 trust store configuration for certificate '" + name
+ "' - cannot read the trust store file '" + config.path() + "'", e);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -68,6 +68,11 @@ protected TrustManager[] engineGetTrustManagers() {

@Override
public Function<String, TrustManager[]> trustManagerMapper(Vertx vertx) {
return name -> new TrustManager[] { TRUST_ALL_MANAGER };
return new Function<String, TrustManager[]>() {
@Override
public TrustManager[] apply(String name) {
return new TrustManager[] { TRUST_ALL_MANAGER };
}
};
}
}
Loading