Skip to content

Commit

Permalink
added truststore&keystorePasword
Browse files Browse the repository at this point in the history
  • Loading branch information
wkd-woo committed Dec 10, 2024
1 parent 943b0c8 commit 1aeef69
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 1 deletion.
8 changes: 8 additions & 0 deletions src/main/java/kafdrop/config/KafkaConfiguration.java
Original file line number Diff line number Diff line change
Expand Up @@ -25,8 +25,10 @@ public final class KafkaConfiguration {
private String saslMechanism;
private String securityProtocol;
private String truststoreFile;
private String truststorePassword;
private String propertiesFile;
private String keystoreFile;
private String keystorePassword;

public void applyCommon(Properties properties) {
properties.setProperty(CommonClientConfigs.BOOTSTRAP_SERVERS_CONFIG, brokerConnect);
Expand All @@ -39,12 +41,18 @@ public void applyCommon(Properties properties) {
if (new File(truststoreFile).isFile()) {
LOG.info("Assigning truststore location to {}", truststoreFile);
properties.put("ssl.truststore.location", truststoreFile);
if (truststorePassword != null && !truststorePassword.isEmpty()) {
properties.put("ssl.truststore.password", truststorePassword);
}
}

LOG.info("Checking keystore file {}", keystoreFile);
if (new File(keystoreFile).isFile()) {
LOG.info("Assigning keystore location to {}", keystoreFile);
properties.put("ssl.keystore.location", keystoreFile);
if (keystorePassword != null && !keystorePassword.isEmpty()) {
properties.put("ssl.keystore.password", keystorePassword);
}
}

LOG.info("Checking properties file {}", propertiesFile);
Expand Down
4 changes: 3 additions & 1 deletion src/main/resources/application.yml
Original file line number Diff line number Diff line change
Expand Up @@ -41,5 +41,7 @@ kafka:
saslMechanism: "PLAIN"
securityProtocol: "SASL_PLAINTEXT"
truststoreFile: "${KAFKA_TRUSTSTORE_FILE:kafka.truststore.jks}"
propertiesFile : "${KAFKA_PROPERTIES_FILE:kafka.properties}"
keystoreFile: "${KAFKA_KEYSTORE_FILE:kafka.keystore.jks}"
propertiesFile: "${KAFKA_PROPERTIES_FILE:kafka.properties}"
truststorePassword: "${KAFKA_TRUSTSTORE_PASSWORD}"
keystorePassword: "${KAFKA_KEYSTORE_PASSWORD}"

0 comments on commit 1aeef69

Please sign in to comment.