This is an automated email from the ASF dual-hosted git repository.
davsclaus pushed a commit to branch main
in repository https://gitbox.apache.org/repos/asf/camel.git
The following commit(s) were added to refs/heads/main by this push:
new 0cdb0a53f02 CAMEL-20954: Cannot share SSLContextParameters between
camel-kafka and other components (#14758)
0cdb0a53f02 is described below
commit 0cdb0a53f02a3ce0e7a39378794c15f94f6ce1cd
Author: Claus Ibsen <[email protected]>
AuthorDate: Tue Jul 9 06:36:16 2024 +0200
CAMEL-20954: Cannot share SSLContextParameters between camel-kafka and
other components (#14758)
---
.../apache/camel/component/kafka/KafkaConfiguration.java | 16 ++++++++++++++--
1 file changed, 14 insertions(+), 2 deletions(-)
diff --git
a/components/camel-kafka/src/main/java/org/apache/camel/component/kafka/KafkaConfiguration.java
b/components/camel-kafka/src/main/java/org/apache/camel/component/kafka/KafkaConfiguration.java
index 25b4ececf6b..49689999ea6 100755
---
a/components/camel-kafka/src/main/java/org/apache/camel/component/kafka/KafkaConfiguration.java
+++
b/components/camel-kafka/src/main/java/org/apache/camel/component/kafka/KafkaConfiguration.java
@@ -38,6 +38,7 @@ import org.apache.camel.spi.StateRepository;
import org.apache.camel.spi.UriParam;
import org.apache.camel.spi.UriParams;
import org.apache.camel.spi.UriPath;
+import org.apache.camel.support.ResourceHelper;
import org.apache.camel.support.jsse.CipherSuitesParameters;
import org.apache.camel.support.jsse.KeyManagersParameters;
import org.apache.camel.support.jsse.KeyStoreParameters;
@@ -45,6 +46,7 @@ import org.apache.camel.support.jsse.SSLContextParameters;
import org.apache.camel.support.jsse.SecureSocketProtocolsParameters;
import org.apache.camel.support.jsse.TrustManagersParameters;
import org.apache.camel.util.ObjectHelper;
+import org.apache.camel.util.StringHelper;
import org.apache.kafka.clients.CommonClientConfigs;
import org.apache.kafka.clients.consumer.ConsumerConfig;
import org.apache.kafka.clients.producer.ProducerConfig;
@@ -570,8 +572,13 @@ public class KafkaConfiguration implements Cloneable,
HeaderFilterStrategyAware
addPropertyIfNotNull(props, SslConfigs.SSL_KEY_PASSWORD_CONFIG,
keyManagers.getKeyPassword());
KeyStoreParameters keyStore = keyManagers.getKeyStore();
if (keyStore != null) {
+ // kakfa loads the resource itself and you cannot have prefix
+ String location = keyStore.getResource();
+ if (ResourceHelper.hasScheme(location)) {
+ location = StringHelper.after(location, ":");
+ }
addUpperCasePropertyIfNotEmpty(props,
SslConfigs.SSL_KEYSTORE_TYPE_CONFIG, keyStore.getType());
- addPropertyIfNotNull(props,
SslConfigs.SSL_KEYSTORE_LOCATION_CONFIG, keyStore.getResource());
+ addPropertyIfNotNull(props,
SslConfigs.SSL_KEYSTORE_LOCATION_CONFIG, location);
addPropertyIfNotNull(props,
SslConfigs.SSL_KEYSTORE_PASSWORD_CONFIG, keyStore.getPassword());
}
}
@@ -581,8 +588,13 @@ public class KafkaConfiguration implements Cloneable,
HeaderFilterStrategyAware
addPropertyIfNotNull(props,
SslConfigs.SSL_TRUSTMANAGER_ALGORITHM_CONFIG, trustManagers.getAlgorithm());
KeyStoreParameters keyStore = trustManagers.getKeyStore();
if (keyStore != null) {
+ // kakfa loads the resource itself and you cannot have prefix
+ String location = keyStore.getResource();
+ if (ResourceHelper.hasScheme(location)) {
+ location = StringHelper.after(location, ":");
+ }
addPropertyIfNotNull(props,
SslConfigs.SSL_TRUSTSTORE_TYPE_CONFIG, keyStore.getType());
- addPropertyIfNotNull(props,
SslConfigs.SSL_TRUSTSTORE_LOCATION_CONFIG, keyStore.getResource());
+ addPropertyIfNotNull(props,
SslConfigs.SSL_TRUSTSTORE_LOCATION_CONFIG, location);
addPropertyIfNotEmpty(props,
SslConfigs.SSL_TRUSTSTORE_PASSWORD_CONFIG, keyStore.getPassword());
}
}