Fixing empty truststore-config in KBCP
* do not copy truststore, if "ssl.truststore.location" is set to empty string (e.g. ssl.truststore.location:{ENV_VARIABLE}) via KafkaBinderConfigurataionProperties.
This commit is contained in:
@@ -64,6 +64,7 @@ import org.springframework.util.StringUtils;
|
||||
* @author Nico Heller
|
||||
* @author Norbert Gyurian
|
||||
* @author Boini Srinivas
|
||||
* @author Felix Schultze
|
||||
*/
|
||||
public class KafkaBinderConfigurationProperties {
|
||||
|
||||
@@ -211,7 +212,7 @@ public class KafkaBinderConfigurationProperties {
|
||||
final String storeLocation = this.configuration.get(storeProperty);
|
||||
|
||||
// If the path is not defined, or it is a local file path do not move the file
|
||||
if (storeLocation != null && !checkIfFileExists(storeLocation)) {
|
||||
if (StringUtils.hasText(storeLocation) && !checkIfFileExists(storeLocation)) {
|
||||
final String fileSystemLocation = moveCertToFileSystem(storeLocation, this.certificateStoreDirectory);
|
||||
// Overriding the value with absolute filesystem path.
|
||||
this.configuration.put(storeProperty, fileSystemLocation);
|
||||
|
||||
@@ -253,6 +253,22 @@ public class KafkaBinderConfigurationPropertiesTest {
|
||||
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testEmptyLocationsAreIgnored() {
|
||||
KafkaProperties kafkaProperties = new KafkaProperties();
|
||||
KafkaBinderConfigurationProperties kafkaBinderConfigurationProperties =
|
||||
new KafkaBinderConfigurationProperties(kafkaProperties);
|
||||
final Map<String, String> configuration = kafkaBinderConfigurationProperties.getConfiguration();
|
||||
configuration.put("schema.registry.ssl.truststore.location", "");
|
||||
configuration.put("schema.registry.ssl.keystore.location", "");
|
||||
kafkaBinderConfigurationProperties.setCertificateStoreDirectory("target");
|
||||
|
||||
kafkaBinderConfigurationProperties.getKafkaConnectionString();
|
||||
|
||||
assertThat(configuration.get("schema.registry.ssl.truststore.location")).isEmpty();
|
||||
assertThat(configuration.get("schema.registry.ssl.keystore.location")).isEmpty();
|
||||
}
|
||||
|
||||
private void createContextWithCertFileHandler(HttpServer server, String path) {
|
||||
server.createContext("/" + path, exchange -> {
|
||||
ClassPathResource ts = new ClassPathResource(path);
|
||||
|
||||
Reference in New Issue
Block a user