diff --git a/src/main/java/io/cryostat/agent/ConfigModule.java b/src/main/java/io/cryostat/agent/ConfigModule.java index d039586e..6860d97c 100644 --- a/src/main/java/io/cryostat/agent/ConfigModule.java +++ b/src/main/java/io/cryostat/agent/ConfigModule.java @@ -16,7 +16,6 @@ package io.cryostat.agent; import java.io.FileInputStream; -import java.io.FileNotFoundException; import java.io.IOException; import java.net.InetAddress; import java.net.URI; @@ -49,7 +48,6 @@ import dagger.Module; import dagger.Provides; - import org.apache.commons.io.IOUtils; import org.eclipse.microprofile.config.Config; import org.eclipse.microprofile.config.ConfigProvider; @@ -277,8 +275,12 @@ public static Optional provideCryostatAgentWebclientTlsTruststorePath(Co @Provides @Singleton @Named(CRYOSTAT_AGENT_WEBCLIENT_TLS_TRUSTSTORE_PASS_FILE) - public static Optional provideCryostatAgentWebclientTlsTruststorePassFromFile(Config config, @Named(CRYOSTAT_AGENT_WEBCLIENT_TLS_TRUSTSTORE_PASS_CHARSET) String passCharset) { - Optional truststorePassFile = config.getOptionalValue(CRYOSTAT_AGENT_WEBCLIENT_TLS_TRUSTSTORE_PASS_FILE, String.class); + public static Optional provideCryostatAgentWebclientTlsTruststorePassFromFile( + Config config, + @Named(CRYOSTAT_AGENT_WEBCLIENT_TLS_TRUSTSTORE_PASS_CHARSET) String passCharset) { + Optional truststorePassFile = + config.getOptionalValue( + CRYOSTAT_AGENT_WEBCLIENT_TLS_TRUSTSTORE_PASS_FILE, String.class); Optional password = Optional.empty(); try (FileInputStream passFile = new FileInputStream(truststorePassFile.get())) { String pass = IOUtils.toString(passFile, Charset.forName(passCharset)); @@ -300,8 +302,12 @@ public static String provideCryostatAgentWebclientTlsTruststorePassCharset(Confi @Provides @Singleton @Named(CRYOSTAT_AGENT_WEBCLIENT_TLS_TRUSTSTORE_PASS) - public static Optional provideCryostatAgentWebclientTlsTruststorePass(Config config, @Named(CRYOSTAT_AGENT_WEBCLIENT_TLS_TRUSTSTORE_PASS_FILE) Optional truststorePass) { - Optional opt = config.getOptionalValue(CRYOSTAT_AGENT_WEBCLIENT_TLS_TRUSTSTORE_PASS, String.class); + public static Optional provideCryostatAgentWebclientTlsTruststorePass( + Config config, + @Named(CRYOSTAT_AGENT_WEBCLIENT_TLS_TRUSTSTORE_PASS_FILE) + Optional truststorePass) { + Optional opt = + config.getOptionalValue(CRYOSTAT_AGENT_WEBCLIENT_TLS_TRUSTSTORE_PASS, String.class); return opt.or(() -> truststorePass); } diff --git a/src/main/java/io/cryostat/agent/MainModule.java b/src/main/java/io/cryostat/agent/MainModule.java index 0e8334a6..8e369d24 100644 --- a/src/main/java/io/cryostat/agent/MainModule.java +++ b/src/main/java/io/cryostat/agent/MainModule.java @@ -132,8 +132,10 @@ public static WebServer provideWebServer( public static SSLContext provideClientSslContext( @Named(ConfigModule.CRYOSTAT_AGENT_WEBCLIENT_TLS_VERSION) String clientTlsVersion, @Named(ConfigModule.CRYOSTAT_AGENT_WEBCLIENT_TLS_TRUST_ALL) boolean trustAll, - @Named(ConfigModule.CRYOSTAT_AGENT_WEBCLIENT_TLS_TRUSTSTORE_PATH) Optional truststorePath, - @Named(ConfigModule.CRYOSTAT_AGENT_WEBCLIENT_TLS_TRUSTSTORE_PASS) Optional truststorePass, + @Named(ConfigModule.CRYOSTAT_AGENT_WEBCLIENT_TLS_TRUSTSTORE_PATH) + Optional truststorePath, + @Named(ConfigModule.CRYOSTAT_AGENT_WEBCLIENT_TLS_TRUSTSTORE_PASS) + Optional truststorePass, @Named(ConfigModule.CRYOSTAT_AGENT_WEBCLIENT_TLS_TRUSTSTORE_TYPE) String truststoreType, @Named(ConfigModule.CRYOSTAT_AGENT_WEBCLIENT_TLS_TRUSTSTORE_CERTS) List truststoreCerts) { @@ -190,7 +192,7 @@ public X509Certificate[] getAcceptedIssuers() { } } - //initialize truststore with user provided certs + // initialize truststore with user provided certs for (TruststoreConfig truststore : truststoreCerts) { // load truststore with certificatesCertificate InputStream certFile = new FileInputStream(truststore.getPath());