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 abf6f8aa83d5 CAMEL-27206: camel-nats - check the host name in the
certificate of the NATS server when TLS is used (#30349)
abf6f8aa83d5 is described below
commit abf6f8aa83d5610a70613a37b46e7e1496a66a24
Author: Claus Ibsen <[email protected]>
AuthorDate: Thu Nov 19 08:41:34 2026 +0100
CAMEL-27206: camel-nats - check the host name in the certificate of the
NATS server when TLS is used (#30349)
jnats checks the certificate of the server against the trust store, but
not that it was issued for the host it connects to. A new
hostnameVerification option (default true, like camel-smpp, camel-mina
and camel-mllp) wraps the SSLContext so its sockets check the host name,
and uses the happy eyeballs mode of jnats, which keeps the host name for
TLS instead of replacing it by an IP address. opentls:// is left as is.
The upgrade guide warns that servers announced by the cluster are used
only on reconnect, so a certificate without them fails only at failover.
Co-Authored-By: Claude Opus 5.5 <[email protected]>
Signed-off-by: Claus Ibsen <[email protected]>
---
.../org/apache/camel/catalog/components/nats.json | 12 +-
.../component/nats/NatsComponentConfigurer.java | 6 +
.../component/nats/NatsEndpointConfigurer.java | 6 +
.../component/nats/NatsEndpointUriFactory.java | 3 +-
.../org/apache/camel/component/nats/nats.json | 12 +-
.../nats/HostnameVerifyingSSLContext.java | 172 +++++++++++++++++++++
.../camel/component/nats/NatsConfiguration.java | 17 ++
.../apache/camel/component/nats/NatsEndpoint.java | 17 ++
.../nats/NatsHostnameVerificationTest.java | 166 ++++++++++++++++++++
.../camel/component/nats/hostname/server.p12 | Bin 0 -> 2584 bytes
.../camel/component/nats/hostname/truststore.p12 | Bin 0 -> 1126 bytes
.../java/org/apache/camel/util/SecurityUtils.java | 1 +
.../ROOT/pages/camel-4x-upgrade-guide-4_24.adoc | 21 +++
.../component/dsl/NatsComponentBuilderFactory.java | 24 +++
.../endpoint/dsl/NatsEndpointBuilderFactory.java | 126 +++++++++++++++
15 files changed, 572 insertions(+), 11 deletions(-)
diff --git
a/catalog/camel-catalog/src/generated/resources/org/apache/camel/catalog/components/nats.json
b/catalog/camel-catalog/src/generated/resources/org/apache/camel/catalog/components/nats.json
index 226c8e3a9081..d75622d20f75 100644
---
a/catalog/camel-catalog/src/generated/resources/org/apache/camel/catalog/components/nats.json
+++
b/catalog/camel-catalog/src/generated/resources/org/apache/camel/catalog/components/nats.json
@@ -65,9 +65,10 @@
"jetstreamAsync": { "index": 38, "kind": "property", "displayName":
"Jetstream Async", "group": "advanced", "label": "advanced", "required": false,
"type": "boolean", "javaType": "boolean", "deprecated": false, "autowired":
false, "secret": false, "defaultValue": true, "configurationClass":
"org.apache.camel.component.nats.NatsConfiguration", "configurationField":
"configuration", "description": "Sets whether to operate JetStream requests
asynchronously." },
"traceConnection": { "index": 39, "kind": "property", "displayName":
"Trace Connection", "group": "advanced", "label": "advanced", "required":
false, "type": "boolean", "javaType": "boolean", "deprecated": false,
"autowired": false, "secret": false, "defaultValue": false,
"configurationClass": "org.apache.camel.component.nats.NatsConfiguration",
"configurationField": "configuration", "description": "Whether or not
connection trace messages should be printed to standard out for fine g [...]
"credentialsFilePath": { "index": 40, "kind": "property", "displayName":
"Credentials File Path", "group": "security", "label": "security", "required":
false, "type": "string", "javaType": "java.lang.String", "deprecated": false,
"autowired": false, "secret": false, "configurationClass":
"org.apache.camel.component.nats.NatsConfiguration", "configurationField":
"configuration", "description": "If we use useCredentialsFile to true we'll
need to set the credentialsFilePath option. It c [...]
- "secure": { "index": 41, "kind": "property", "displayName": "Secure",
"group": "security", "label": "security", "required": false, "type": "boolean",
"javaType": "boolean", "deprecated": false, "autowired": false, "secret":
false, "defaultValue": false, "configurationClass":
"org.apache.camel.component.nats.NatsConfiguration", "configurationField":
"configuration", "description": "Set secure option indicating TLS is required"
},
- "sslContextParameters": { "index": 42, "kind": "property", "displayName":
"Ssl Context Parameters", "group": "security", "label": "security", "required":
false, "type": "object", "javaType":
"org.apache.camel.support.jsse.SSLContextParameters", "deprecated": false,
"autowired": false, "secret": false, "configurationClass":
"org.apache.camel.component.nats.NatsConfiguration", "configurationField":
"configuration", "description": "To configure security using
SSLContextParameters" },
- "useGlobalSslContextParameters": { "index": 43, "kind": "property",
"displayName": "Use Global Ssl Context Parameters", "group": "security",
"label": "security", "required": false, "type": "boolean", "javaType":
"boolean", "deprecated": false, "autowired": false, "secret": false,
"defaultValue": false, "description": "Enable usage of global SSL context
parameters." }
+ "hostnameVerification": { "index": 41, "kind": "property", "displayName":
"Hostname Verification", "group": "security", "label": "security", "required":
false, "type": "boolean", "javaType": "boolean", "deprecated": false,
"autowired": false, "secret": false, "security": "insecure:ssl",
"insecureValue": "false", "defaultValue": true, "configurationClass":
"org.apache.camel.component.nats.NatsConfiguration", "configurationField":
"configuration", "description": "Whether to check that [...]
+ "secure": { "index": 42, "kind": "property", "displayName": "Secure",
"group": "security", "label": "security", "required": false, "type": "boolean",
"javaType": "boolean", "deprecated": false, "autowired": false, "secret":
false, "defaultValue": false, "configurationClass":
"org.apache.camel.component.nats.NatsConfiguration", "configurationField":
"configuration", "description": "Set secure option indicating TLS is required"
},
+ "sslContextParameters": { "index": 43, "kind": "property", "displayName":
"Ssl Context Parameters", "group": "security", "label": "security", "required":
false, "type": "object", "javaType":
"org.apache.camel.support.jsse.SSLContextParameters", "deprecated": false,
"autowired": false, "secret": false, "configurationClass":
"org.apache.camel.component.nats.NatsConfiguration", "configurationField":
"configuration", "description": "To configure security using
SSLContextParameters" },
+ "useGlobalSslContextParameters": { "index": 44, "kind": "property",
"displayName": "Use Global Ssl Context Parameters", "group": "security",
"label": "security", "required": false, "type": "boolean", "javaType":
"boolean", "deprecated": false, "autowired": false, "secret": false,
"defaultValue": false, "description": "Enable usage of global SSL context
parameters." }
},
"headers": {
"CamelNatsMessageTimestamp": { "index": 0, "kind": "header",
"displayName": "", "group": "common", "label": "", "required": false,
"javaType": "long", "deprecated": false, "autowired": false, "secret": false,
"description": "The timestamp of a consumed message.", "constantName":
"org.apache.camel.component.nats.NatsConstants#NATS_MESSAGE_TIMESTAMP" },
@@ -129,8 +130,9 @@
"jetstreamAsync": { "index": 39, "kind": "parameter", "displayName":
"Jetstream Async", "group": "advanced", "label": "advanced", "required": false,
"type": "boolean", "javaType": "boolean", "deprecated": false, "autowired":
false, "secret": false, "defaultValue": true, "configurationClass":
"org.apache.camel.component.nats.NatsConfiguration", "configurationField":
"configuration", "description": "Sets whether to operate JetStream requests
asynchronously." },
"traceConnection": { "index": 40, "kind": "parameter", "displayName":
"Trace Connection", "group": "advanced", "label": "advanced", "required":
false, "type": "boolean", "javaType": "boolean", "deprecated": false,
"autowired": false, "secret": false, "defaultValue": false,
"configurationClass": "org.apache.camel.component.nats.NatsConfiguration",
"configurationField": "configuration", "description": "Whether or not
connection trace messages should be printed to standard out for fine [...]
"credentialsFilePath": { "index": 41, "kind": "parameter", "displayName":
"Credentials File Path", "group": "security", "label": "security", "required":
false, "type": "string", "javaType": "java.lang.String", "deprecated": false,
"autowired": false, "secret": false, "configurationClass":
"org.apache.camel.component.nats.NatsConfiguration", "configurationField":
"configuration", "description": "If we use useCredentialsFile to true we'll
need to set the credentialsFilePath option. It [...]
- "secure": { "index": 42, "kind": "parameter", "displayName": "Secure",
"group": "security", "label": "security", "required": false, "type": "boolean",
"javaType": "boolean", "deprecated": false, "autowired": false, "secret":
false, "defaultValue": false, "configurationClass":
"org.apache.camel.component.nats.NatsConfiguration", "configurationField":
"configuration", "description": "Set secure option indicating TLS is required"
},
- "sslContextParameters": { "index": 43, "kind": "parameter", "displayName":
"Ssl Context Parameters", "group": "security", "label": "security", "required":
false, "type": "object", "javaType":
"org.apache.camel.support.jsse.SSLContextParameters", "deprecated": false,
"autowired": false, "secret": false, "configurationClass":
"org.apache.camel.component.nats.NatsConfiguration", "configurationField":
"configuration", "description": "To configure security using
SSLContextParameters" }
+ "hostnameVerification": { "index": 42, "kind": "parameter", "displayName":
"Hostname Verification", "group": "security", "label": "security", "required":
false, "type": "boolean", "javaType": "boolean", "deprecated": false,
"autowired": false, "secret": false, "security": "insecure:ssl",
"insecureValue": "false", "defaultValue": true, "configurationClass":
"org.apache.camel.component.nats.NatsConfiguration", "configurationField":
"configuration", "description": "Whether to check that [...]
+ "secure": { "index": 43, "kind": "parameter", "displayName": "Secure",
"group": "security", "label": "security", "required": false, "type": "boolean",
"javaType": "boolean", "deprecated": false, "autowired": false, "secret":
false, "defaultValue": false, "configurationClass":
"org.apache.camel.component.nats.NatsConfiguration", "configurationField":
"configuration", "description": "Set secure option indicating TLS is required"
},
+ "sslContextParameters": { "index": 44, "kind": "parameter", "displayName":
"Ssl Context Parameters", "group": "security", "label": "security", "required":
false, "type": "object", "javaType":
"org.apache.camel.support.jsse.SSLContextParameters", "deprecated": false,
"autowired": false, "secret": false, "configurationClass":
"org.apache.camel.component.nats.NatsConfiguration", "configurationField":
"configuration", "description": "To configure security using
SSLContextParameters" }
},
"dstWorlds": {
"NatsWorld": { "javaType":
"org.apache.camel.component.nats.dst.NatsWorld", "fake": "FakeJetStream: a
server with one JetStream stream and its pull consumers (AckWait, MaxDeliver,
Nak), behind a jnats Connection given with the connection option", "covers": [
"the JetStream pull consumer with explicit acks and naks, ephemeral or
durable", "AckWait and MaxDeliver", "route stop and start, also while the
consumer waits in a fetch", "a server restart that deletes the ephemeral
consumer, a [...]
diff --git
a/components/camel-nats/src/generated/java/org/apache/camel/component/nats/NatsComponentConfigurer.java
b/components/camel-nats/src/generated/java/org/apache/camel/component/nats/NatsComponentConfigurer.java
index 43626873aac2..44af8f43a792 100644
---
a/components/camel-nats/src/generated/java/org/apache/camel/component/nats/NatsComponentConfigurer.java
+++
b/components/camel-nats/src/generated/java/org/apache/camel/component/nats/NatsComponentConfigurer.java
@@ -55,6 +55,8 @@ public class NatsComponentConfigurer extends
PropertyConfigurerSupport implement
case "flushTimeout":
getOrCreateConfiguration(target).setFlushTimeout(property(camelContext,
int.class, value)); return true;
case "headerfilterstrategy":
case "headerFilterStrategy":
getOrCreateConfiguration(target).setHeaderFilterStrategy(property(camelContext,
org.apache.camel.spi.HeaderFilterStrategy.class, value)); return true;
+ case "hostnameverification":
+ case "hostnameVerification":
getOrCreateConfiguration(target).setHostnameVerification(property(camelContext,
boolean.class, value)); return true;
case "jetstreamasync":
case "jetstreamAsync":
getOrCreateConfiguration(target).setJetstreamAsync(property(camelContext,
boolean.class, value)); return true;
case "jetstreamenabled":
@@ -143,6 +145,8 @@ public class NatsComponentConfigurer extends
PropertyConfigurerSupport implement
case "flushTimeout": return int.class;
case "headerfilterstrategy":
case "headerFilterStrategy": return
org.apache.camel.spi.HeaderFilterStrategy.class;
+ case "hostnameverification":
+ case "hostnameVerification": return boolean.class;
case "jetstreamasync":
case "jetstreamAsync": return boolean.class;
case "jetstreamenabled":
@@ -232,6 +236,8 @@ public class NatsComponentConfigurer extends
PropertyConfigurerSupport implement
case "flushTimeout": return
getOrCreateConfiguration(target).getFlushTimeout();
case "headerfilterstrategy":
case "headerFilterStrategy": return
getOrCreateConfiguration(target).getHeaderFilterStrategy();
+ case "hostnameverification":
+ case "hostnameVerification": return
getOrCreateConfiguration(target).isHostnameVerification();
case "jetstreamasync":
case "jetstreamAsync": return
getOrCreateConfiguration(target).isJetstreamAsync();
case "jetstreamenabled":
diff --git
a/components/camel-nats/src/generated/java/org/apache/camel/component/nats/NatsEndpointConfigurer.java
b/components/camel-nats/src/generated/java/org/apache/camel/component/nats/NatsEndpointConfigurer.java
index b24ec8a75098..b4b13ef2c053 100644
---
a/components/camel-nats/src/generated/java/org/apache/camel/component/nats/NatsEndpointConfigurer.java
+++
b/components/camel-nats/src/generated/java/org/apache/camel/component/nats/NatsEndpointConfigurer.java
@@ -49,6 +49,8 @@ public class NatsEndpointConfigurer extends
PropertyConfigurerSupport implements
case "flushTimeout":
target.getConfiguration().setFlushTimeout(property(camelContext, int.class,
value)); return true;
case "headerfilterstrategy":
case "headerFilterStrategy":
target.getConfiguration().setHeaderFilterStrategy(property(camelContext,
org.apache.camel.spi.HeaderFilterStrategy.class, value)); return true;
+ case "hostnameverification":
+ case "hostnameVerification":
target.getConfiguration().setHostnameVerification(property(camelContext,
boolean.class, value)); return true;
case "jetstreamasync":
case "jetstreamAsync":
target.getConfiguration().setJetstreamAsync(property(camelContext,
boolean.class, value)); return true;
case "jetstreamenabled":
@@ -136,6 +138,8 @@ public class NatsEndpointConfigurer extends
PropertyConfigurerSupport implements
case "flushTimeout": return int.class;
case "headerfilterstrategy":
case "headerFilterStrategy": return
org.apache.camel.spi.HeaderFilterStrategy.class;
+ case "hostnameverification":
+ case "hostnameVerification": return boolean.class;
case "jetstreamasync":
case "jetstreamAsync": return boolean.class;
case "jetstreamenabled":
@@ -224,6 +228,8 @@ public class NatsEndpointConfigurer extends
PropertyConfigurerSupport implements
case "flushTimeout": return
target.getConfiguration().getFlushTimeout();
case "headerfilterstrategy":
case "headerFilterStrategy": return
target.getConfiguration().getHeaderFilterStrategy();
+ case "hostnameverification":
+ case "hostnameVerification": return
target.getConfiguration().isHostnameVerification();
case "jetstreamasync":
case "jetstreamAsync": return
target.getConfiguration().isJetstreamAsync();
case "jetstreamenabled":
diff --git
a/components/camel-nats/src/generated/java/org/apache/camel/component/nats/NatsEndpointUriFactory.java
b/components/camel-nats/src/generated/java/org/apache/camel/component/nats/NatsEndpointUriFactory.java
index 03bfadedd2fd..d6f859c883dd 100644
---
a/components/camel-nats/src/generated/java/org/apache/camel/component/nats/NatsEndpointUriFactory.java
+++
b/components/camel-nats/src/generated/java/org/apache/camel/component/nats/NatsEndpointUriFactory.java
@@ -24,7 +24,7 @@ public class NatsEndpointUriFactory extends
org.apache.camel.support.component.E
private static final Set<String> ENDPOINT_IDENTITY_PROPERTY_NAMES;
private static final Map<String, String> MULTI_VALUE_PREFIXES;
static {
- Set<String> props = new HashSet<>(44);
+ Set<String> props = new HashSet<>(45);
props.add("ackPolicy");
props.add("ackWait");
props.add("bridgeErrorHandler");
@@ -38,6 +38,7 @@ public class NatsEndpointUriFactory extends
org.apache.camel.support.component.E
props.add("flushConnection");
props.add("flushTimeout");
props.add("headerFilterStrategy");
+ props.add("hostnameVerification");
props.add("jetstreamAsync");
props.add("jetstreamEnabled");
props.add("jetstreamName");
diff --git
a/components/camel-nats/src/generated/resources/META-INF/org/apache/camel/component/nats/nats.json
b/components/camel-nats/src/generated/resources/META-INF/org/apache/camel/component/nats/nats.json
index 226c8e3a9081..d75622d20f75 100644
---
a/components/camel-nats/src/generated/resources/META-INF/org/apache/camel/component/nats/nats.json
+++
b/components/camel-nats/src/generated/resources/META-INF/org/apache/camel/component/nats/nats.json
@@ -65,9 +65,10 @@
"jetstreamAsync": { "index": 38, "kind": "property", "displayName":
"Jetstream Async", "group": "advanced", "label": "advanced", "required": false,
"type": "boolean", "javaType": "boolean", "deprecated": false, "autowired":
false, "secret": false, "defaultValue": true, "configurationClass":
"org.apache.camel.component.nats.NatsConfiguration", "configurationField":
"configuration", "description": "Sets whether to operate JetStream requests
asynchronously." },
"traceConnection": { "index": 39, "kind": "property", "displayName":
"Trace Connection", "group": "advanced", "label": "advanced", "required":
false, "type": "boolean", "javaType": "boolean", "deprecated": false,
"autowired": false, "secret": false, "defaultValue": false,
"configurationClass": "org.apache.camel.component.nats.NatsConfiguration",
"configurationField": "configuration", "description": "Whether or not
connection trace messages should be printed to standard out for fine g [...]
"credentialsFilePath": { "index": 40, "kind": "property", "displayName":
"Credentials File Path", "group": "security", "label": "security", "required":
false, "type": "string", "javaType": "java.lang.String", "deprecated": false,
"autowired": false, "secret": false, "configurationClass":
"org.apache.camel.component.nats.NatsConfiguration", "configurationField":
"configuration", "description": "If we use useCredentialsFile to true we'll
need to set the credentialsFilePath option. It c [...]
- "secure": { "index": 41, "kind": "property", "displayName": "Secure",
"group": "security", "label": "security", "required": false, "type": "boolean",
"javaType": "boolean", "deprecated": false, "autowired": false, "secret":
false, "defaultValue": false, "configurationClass":
"org.apache.camel.component.nats.NatsConfiguration", "configurationField":
"configuration", "description": "Set secure option indicating TLS is required"
},
- "sslContextParameters": { "index": 42, "kind": "property", "displayName":
"Ssl Context Parameters", "group": "security", "label": "security", "required":
false, "type": "object", "javaType":
"org.apache.camel.support.jsse.SSLContextParameters", "deprecated": false,
"autowired": false, "secret": false, "configurationClass":
"org.apache.camel.component.nats.NatsConfiguration", "configurationField":
"configuration", "description": "To configure security using
SSLContextParameters" },
- "useGlobalSslContextParameters": { "index": 43, "kind": "property",
"displayName": "Use Global Ssl Context Parameters", "group": "security",
"label": "security", "required": false, "type": "boolean", "javaType":
"boolean", "deprecated": false, "autowired": false, "secret": false,
"defaultValue": false, "description": "Enable usage of global SSL context
parameters." }
+ "hostnameVerification": { "index": 41, "kind": "property", "displayName":
"Hostname Verification", "group": "security", "label": "security", "required":
false, "type": "boolean", "javaType": "boolean", "deprecated": false,
"autowired": false, "secret": false, "security": "insecure:ssl",
"insecureValue": "false", "defaultValue": true, "configurationClass":
"org.apache.camel.component.nats.NatsConfiguration", "configurationField":
"configuration", "description": "Whether to check that [...]
+ "secure": { "index": 42, "kind": "property", "displayName": "Secure",
"group": "security", "label": "security", "required": false, "type": "boolean",
"javaType": "boolean", "deprecated": false, "autowired": false, "secret":
false, "defaultValue": false, "configurationClass":
"org.apache.camel.component.nats.NatsConfiguration", "configurationField":
"configuration", "description": "Set secure option indicating TLS is required"
},
+ "sslContextParameters": { "index": 43, "kind": "property", "displayName":
"Ssl Context Parameters", "group": "security", "label": "security", "required":
false, "type": "object", "javaType":
"org.apache.camel.support.jsse.SSLContextParameters", "deprecated": false,
"autowired": false, "secret": false, "configurationClass":
"org.apache.camel.component.nats.NatsConfiguration", "configurationField":
"configuration", "description": "To configure security using
SSLContextParameters" },
+ "useGlobalSslContextParameters": { "index": 44, "kind": "property",
"displayName": "Use Global Ssl Context Parameters", "group": "security",
"label": "security", "required": false, "type": "boolean", "javaType":
"boolean", "deprecated": false, "autowired": false, "secret": false,
"defaultValue": false, "description": "Enable usage of global SSL context
parameters." }
},
"headers": {
"CamelNatsMessageTimestamp": { "index": 0, "kind": "header",
"displayName": "", "group": "common", "label": "", "required": false,
"javaType": "long", "deprecated": false, "autowired": false, "secret": false,
"description": "The timestamp of a consumed message.", "constantName":
"org.apache.camel.component.nats.NatsConstants#NATS_MESSAGE_TIMESTAMP" },
@@ -129,8 +130,9 @@
"jetstreamAsync": { "index": 39, "kind": "parameter", "displayName":
"Jetstream Async", "group": "advanced", "label": "advanced", "required": false,
"type": "boolean", "javaType": "boolean", "deprecated": false, "autowired":
false, "secret": false, "defaultValue": true, "configurationClass":
"org.apache.camel.component.nats.NatsConfiguration", "configurationField":
"configuration", "description": "Sets whether to operate JetStream requests
asynchronously." },
"traceConnection": { "index": 40, "kind": "parameter", "displayName":
"Trace Connection", "group": "advanced", "label": "advanced", "required":
false, "type": "boolean", "javaType": "boolean", "deprecated": false,
"autowired": false, "secret": false, "defaultValue": false,
"configurationClass": "org.apache.camel.component.nats.NatsConfiguration",
"configurationField": "configuration", "description": "Whether or not
connection trace messages should be printed to standard out for fine [...]
"credentialsFilePath": { "index": 41, "kind": "parameter", "displayName":
"Credentials File Path", "group": "security", "label": "security", "required":
false, "type": "string", "javaType": "java.lang.String", "deprecated": false,
"autowired": false, "secret": false, "configurationClass":
"org.apache.camel.component.nats.NatsConfiguration", "configurationField":
"configuration", "description": "If we use useCredentialsFile to true we'll
need to set the credentialsFilePath option. It [...]
- "secure": { "index": 42, "kind": "parameter", "displayName": "Secure",
"group": "security", "label": "security", "required": false, "type": "boolean",
"javaType": "boolean", "deprecated": false, "autowired": false, "secret":
false, "defaultValue": false, "configurationClass":
"org.apache.camel.component.nats.NatsConfiguration", "configurationField":
"configuration", "description": "Set secure option indicating TLS is required"
},
- "sslContextParameters": { "index": 43, "kind": "parameter", "displayName":
"Ssl Context Parameters", "group": "security", "label": "security", "required":
false, "type": "object", "javaType":
"org.apache.camel.support.jsse.SSLContextParameters", "deprecated": false,
"autowired": false, "secret": false, "configurationClass":
"org.apache.camel.component.nats.NatsConfiguration", "configurationField":
"configuration", "description": "To configure security using
SSLContextParameters" }
+ "hostnameVerification": { "index": 42, "kind": "parameter", "displayName":
"Hostname Verification", "group": "security", "label": "security", "required":
false, "type": "boolean", "javaType": "boolean", "deprecated": false,
"autowired": false, "secret": false, "security": "insecure:ssl",
"insecureValue": "false", "defaultValue": true, "configurationClass":
"org.apache.camel.component.nats.NatsConfiguration", "configurationField":
"configuration", "description": "Whether to check that [...]
+ "secure": { "index": 43, "kind": "parameter", "displayName": "Secure",
"group": "security", "label": "security", "required": false, "type": "boolean",
"javaType": "boolean", "deprecated": false, "autowired": false, "secret":
false, "defaultValue": false, "configurationClass":
"org.apache.camel.component.nats.NatsConfiguration", "configurationField":
"configuration", "description": "Set secure option indicating TLS is required"
},
+ "sslContextParameters": { "index": 44, "kind": "parameter", "displayName":
"Ssl Context Parameters", "group": "security", "label": "security", "required":
false, "type": "object", "javaType":
"org.apache.camel.support.jsse.SSLContextParameters", "deprecated": false,
"autowired": false, "secret": false, "configurationClass":
"org.apache.camel.component.nats.NatsConfiguration", "configurationField":
"configuration", "description": "To configure security using
SSLContextParameters" }
},
"dstWorlds": {
"NatsWorld": { "javaType":
"org.apache.camel.component.nats.dst.NatsWorld", "fake": "FakeJetStream: a
server with one JetStream stream and its pull consumers (AckWait, MaxDeliver,
Nak), behind a jnats Connection given with the connection option", "covers": [
"the JetStream pull consumer with explicit acks and naks, ephemeral or
durable", "AckWait and MaxDeliver", "route stop and start, also while the
consumer waits in a fetch", "a server restart that deletes the ephemeral
consumer, a [...]
diff --git
a/components/camel-nats/src/main/java/org/apache/camel/component/nats/HostnameVerifyingSSLContext.java
b/components/camel-nats/src/main/java/org/apache/camel/component/nats/HostnameVerifyingSSLContext.java
new file mode 100644
index 000000000000..9e14f812aa66
--- /dev/null
+++
b/components/camel-nats/src/main/java/org/apache/camel/component/nats/HostnameVerifyingSSLContext.java
@@ -0,0 +1,172 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.camel.component.nats;
+
+import java.io.IOException;
+import java.io.InputStream;
+import java.net.InetAddress;
+import java.net.Socket;
+import java.security.KeyManagementException;
+import java.security.SecureRandom;
+
+import javax.net.ssl.KeyManager;
+import javax.net.ssl.SSLContext;
+import javax.net.ssl.SSLContextSpi;
+import javax.net.ssl.SSLEngine;
+import javax.net.ssl.SSLParameters;
+import javax.net.ssl.SSLServerSocketFactory;
+import javax.net.ssl.SSLSessionContext;
+import javax.net.ssl.SSLSocket;
+import javax.net.ssl.SSLSocketFactory;
+import javax.net.ssl.TrustManager;
+
+/**
+ * An SSLContext whose client sockets and engines check that the certificate
of the server was issued for the host they
+ * connect to, as jnats does not ask for it.
+ */
+final class HostnameVerifyingSSLContext extends SSLContext {
+
+ private HostnameVerifyingSSLContext(SSLContext delegate) {
+ super(new Spi(delegate), delegate.getProvider(),
delegate.getProtocol());
+ }
+
+ static SSLContext wrap(SSLContext context) {
+ return context instanceof HostnameVerifyingSSLContext ? context : new
HostnameVerifyingSSLContext(context);
+ }
+
+ private static <T> T verifyHostname(T socket) {
+ if (socket instanceof SSLSocket sslSocket) {
+ SSLParameters parameters = sslSocket.getSSLParameters();
+ parameters.setEndpointIdentificationAlgorithm("HTTPS");
+ sslSocket.setSSLParameters(parameters);
+ } else if (socket instanceof SSLEngine engine) {
+ SSLParameters parameters = engine.getSSLParameters();
+ parameters.setEndpointIdentificationAlgorithm("HTTPS");
+ engine.setSSLParameters(parameters);
+ }
+ return socket;
+ }
+
+ private static final class Spi extends SSLContextSpi {
+
+ private final SSLContext delegate;
+
+ Spi(SSLContext delegate) {
+ this.delegate = delegate;
+ }
+
+ @Override
+ protected void engineInit(KeyManager[] km, TrustManager[] tm,
SecureRandom sr) throws KeyManagementException {
+ delegate.init(km, tm, sr);
+ }
+
+ @Override
+ protected SSLSocketFactory engineGetSocketFactory() {
+ return new SocketFactory(delegate.getSocketFactory());
+ }
+
+ @Override
+ protected SSLServerSocketFactory engineGetServerSocketFactory() {
+ return delegate.getServerSocketFactory();
+ }
+
+ @Override
+ protected SSLEngine engineCreateSSLEngine() {
+ return verifyHostname(delegate.createSSLEngine());
+ }
+
+ @Override
+ protected SSLEngine engineCreateSSLEngine(String host, int port) {
+ return verifyHostname(delegate.createSSLEngine(host, port));
+ }
+
+ @Override
+ protected SSLSessionContext engineGetServerSessionContext() {
+ return delegate.getServerSessionContext();
+ }
+
+ @Override
+ protected SSLSessionContext engineGetClientSessionContext() {
+ return delegate.getClientSessionContext();
+ }
+
+ @Override
+ protected SSLParameters engineGetDefaultSSLParameters() {
+ return delegate.getDefaultSSLParameters();
+ }
+
+ @Override
+ protected SSLParameters engineGetSupportedSSLParameters() {
+ return delegate.getSupportedSSLParameters();
+ }
+ }
+
+ private static final class SocketFactory extends SSLSocketFactory {
+
+ private final SSLSocketFactory delegate;
+
+ SocketFactory(SSLSocketFactory delegate) {
+ this.delegate = delegate;
+ }
+
+ @Override
+ public String[] getDefaultCipherSuites() {
+ return delegate.getDefaultCipherSuites();
+ }
+
+ @Override
+ public String[] getSupportedCipherSuites() {
+ return delegate.getSupportedCipherSuites();
+ }
+
+ @Override
+ public Socket createSocket() throws IOException {
+ return verifyHostname(delegate.createSocket());
+ }
+
+ @Override
+ public Socket createSocket(Socket s, String host, int port, boolean
autoClose) throws IOException {
+ return verifyHostname(delegate.createSocket(s, host, port,
autoClose));
+ }
+
+ @Override
+ public Socket createSocket(Socket s, InputStream consumed, boolean
autoClose) throws IOException {
+ return verifyHostname(delegate.createSocket(s, consumed,
autoClose));
+ }
+
+ @Override
+ public Socket createSocket(String host, int port) throws IOException {
+ return verifyHostname(delegate.createSocket(host, port));
+ }
+
+ @Override
+ public Socket createSocket(String host, int port, InetAddress
localHost, int localPort) throws IOException {
+ return verifyHostname(delegate.createSocket(host, port, localHost,
localPort));
+ }
+
+ @Override
+ public Socket createSocket(InetAddress host, int port) throws
IOException {
+ return verifyHostname(delegate.createSocket(host, port));
+ }
+
+ @Override
+ public Socket createSocket(InetAddress address, int port, InetAddress
localAddress, int localPort)
+ throws IOException {
+ return verifyHostname(delegate.createSocket(address, port,
localAddress, localPort));
+ }
+ }
+}
diff --git
a/components/camel-nats/src/main/java/org/apache/camel/component/nats/NatsConfiguration.java
b/components/camel-nats/src/main/java/org/apache/camel/component/nats/NatsConfiguration.java
index 00b489098c7b..a17a57130e7c 100644
---
a/components/camel-nats/src/main/java/org/apache/camel/component/nats/NatsConfiguration.java
+++
b/components/camel-nats/src/main/java/org/apache/camel/component/nats/NatsConfiguration.java
@@ -111,6 +111,8 @@ public class NatsConfiguration implements Cloneable {
private boolean secure;
@UriParam(label = "security")
private SSLContextParameters sslContextParameters;
+ @UriParam(label = "security", defaultValue = "true", security =
"insecure:ssl", insecureValue = "false")
+ private boolean hostnameVerification = true;
@UriParam(label = "security")
String credentialsFilePath;
@UriParam(label = "advanced")
@@ -405,6 +407,21 @@ public class NatsConfiguration implements Cloneable {
this.sslContextParameters = sslContextParameters;
}
+ public boolean isHostnameVerification() {
+ return hostnameVerification;
+ }
+
+ /**
+ * Whether to check that the certificate of the NATS server matches the
host Camel connects to, when TLS is used.
+ * The client then keeps the host name of a server for TLS, and connects
to the fastest of its IP addresses. A
+ * server that is given, or that the cluster announces, by its IP address
needs a certificate that names that
+ * address. When disabled, any certificate trusted by the JVM, or by the
sslContextParameters, is accepted, whatever
+ * host it was issued for.
+ */
+ public void setHostnameVerification(boolean hostnameVerification) {
+ this.hostnameVerification = hostnameVerification;
+ }
+
/**
* If we use useCredentialsFile to true we'll need to set the
credentialsFilePath option. It can be loaded by
* default from classpath, but you can prefix with classpath:, file:, or
http: to load the resource from different
diff --git
a/components/camel-nats/src/main/java/org/apache/camel/component/nats/NatsEndpoint.java
b/components/camel-nats/src/main/java/org/apache/camel/component/nats/NatsEndpoint.java
index 321fea7ed9ee..6ec8f57065e3 100644
---
a/components/camel-nats/src/main/java/org/apache/camel/component/nats/NatsEndpoint.java
+++
b/components/camel-nats/src/main/java/org/apache/camel/component/nats/NatsEndpoint.java
@@ -18,6 +18,7 @@ package org.apache.camel.component.nats;
import java.io.IOException;
import java.security.GeneralSecurityException;
+import java.util.Locale;
import java.util.concurrent.ExecutorService;
import javax.net.ssl.SSLContext;
@@ -26,6 +27,7 @@ import io.nats.client.Connection;
import io.nats.client.Nats;
import io.nats.client.Options;
import io.nats.client.Options.Builder;
+import io.nats.client.Options.HostnameResolveMode;
import org.apache.camel.Category;
import org.apache.camel.Consumer;
import org.apache.camel.MultipleConsumersSupport;
@@ -133,9 +135,24 @@ public class NatsEndpoint extends DefaultEndpoint
.getInputStream().readAllBytes()));
}
Options options = builder.build();
+ if (getConfiguration().isHostnameVerification() &&
options.getSslContext() != null && !isTrustAll()) {
+ // jnats checks the certificate of the server, but not that it was
issued for the host. By default it also
+ // replaces a host name by its IP addresses, so TLS would only see
an IP address. Happy eyeballs connects to
+ // the addresses of the host name itself and keeps the name for
TLS.
+ options = new Builder(options)
+
.sslContext(HostnameVerifyingSSLContext.wrap(options.getSslContext()))
+ .hostnameResolveMode(HostnameResolveMode.HappyEyeballs)
+ .build();
+ }
return Nats.connect(options);
}
+ private boolean isTrustAll() {
+ // opentls:// asks jnats to trust every server certificate
+ String servers = getConfiguration().getServers();
+ return servers != null &&
servers.toLowerCase(Locale.ROOT).contains("opentls://");
+ }
+
@Override
public HeaderFilterStrategy getHeaderFilterStrategy() {
return getConfiguration().getHeaderFilterStrategy();
diff --git
a/components/camel-nats/src/test/java/org/apache/camel/component/nats/NatsHostnameVerificationTest.java
b/components/camel-nats/src/test/java/org/apache/camel/component/nats/NatsHostnameVerificationTest.java
new file mode 100644
index 000000000000..094d7c4792cf
--- /dev/null
+++
b/components/camel-nats/src/test/java/org/apache/camel/component/nats/NatsHostnameVerificationTest.java
@@ -0,0 +1,166 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.camel.component.nats;
+
+import java.io.IOException;
+import java.io.InputStream;
+import java.net.InetSocketAddress;
+import java.net.ServerSocket;
+import java.net.Socket;
+import java.nio.charset.StandardCharsets;
+import java.security.KeyStore;
+import java.util.concurrent.CompletableFuture;
+import java.util.concurrent.ExecutorService;
+import java.util.concurrent.Executors;
+import java.util.concurrent.TimeUnit;
+
+import javax.net.ssl.KeyManagerFactory;
+import javax.net.ssl.SSLContext;
+import javax.net.ssl.SSLSocket;
+
+import io.nats.client.Connection;
+import org.apache.camel.BindToRegistry;
+import org.apache.camel.support.jsse.KeyStoreParameters;
+import org.apache.camel.support.jsse.SSLContextParameters;
+import org.apache.camel.support.jsse.TrustManagersParameters;
+import org.apache.camel.test.junit6.CamelTestSupport;
+import org.junit.jupiter.api.AfterEach;
+import org.junit.jupiter.api.Test;
+
+import static org.junit.jupiter.api.Assertions.assertFalse;
+import static org.junit.jupiter.api.Assertions.assertTrue;
+
+/**
+ * Connects with TLS to a local server whose certificate is issued for
localhost only, to check that the host name in
+ * the certificate is checked.
+ */
+public class NatsHostnameVerificationTest extends CamelTestSupport {
+
+ private static final String RESOURCES =
"org/apache/camel/component/nats/hostname/";
+ private static final String PASSWORD = "changeit";
+ private static final long TIMEOUT_SECONDS = 20;
+
+ private final ExecutorService executor =
Executors.newSingleThreadExecutor();
+ private ServerSocket server;
+
+ @BindToRegistry("ssl")
+ public SSLContextParameters ssl() {
+ KeyStoreParameters trustStore = new KeyStoreParameters();
+ trustStore.setResource("classpath:" + RESOURCES + "truststore.p12");
+ trustStore.setType("PKCS12");
+ trustStore.setPassword(PASSWORD);
+ TrustManagersParameters trustManagers = new TrustManagersParameters();
+ trustManagers.setKeyStore(trustStore);
+ SSLContextParameters ssl = new SSLContextParameters();
+ ssl.setTrustManagers(trustManagers);
+ return ssl;
+ }
+
+ @AfterEach
+ void stopServer() throws IOException {
+ if (server != null) {
+ server.close();
+ }
+ executor.shutdownNow();
+ }
+
+ @Test
+ void certificateForAnotherHostIsRefused() throws Exception {
+ CompletableFuture<Boolean> handshake = startServer();
+
+ // the certificate names localhost, not the IP address
+ connect("127.0.0.1", "");
+
+ assertFalse(handshake.get(TIMEOUT_SECONDS, TimeUnit.SECONDS),
+ "the certificate does not name the host, so the connection
must fail");
+ }
+
+ @Test
+ void certificateForTheHostIsAccepted() throws Exception {
+ CompletableFuture<Boolean> handshake = startServer();
+
+ connect("localhost", "");
+
+ assertTrue(handshake.get(TIMEOUT_SECONDS, TimeUnit.SECONDS), "the
certificate names the host");
+ }
+
+ @Test
+ void hostnameVerificationCanBeTurnedOff() throws Exception {
+ CompletableFuture<Boolean> handshake = startServer();
+
+ connect("127.0.0.1", "&hostnameVerification=false");
+
+ assertTrue(handshake.get(TIMEOUT_SECONDS, TimeUnit.SECONDS),
+ "without the host name check, a trusted certificate is
accepted for any host");
+ }
+
+ private void connect(String host, String options) {
+ NatsEndpoint endpoint = context.getEndpoint("nats:test?servers=" +
host + ":" + server.getLocalPort()
+ +
"&secure=true&sslContextParameters=#ssl&reconnect=false"
+ + options,
+ NatsEndpoint.class);
+ try (Connection connection = endpoint.getConnection()) {
+ // the server is not a NATS server: it only does the TLS handshake
+ } catch (Exception e) {
+ // expected, the server does not answer the CONNECT
+ }
+ }
+
+ /**
+ * Starts a server that sends the INFO line of a NATS server that requires
TLS, then does the TLS handshake with the
+ * certificate for localhost, for the first connection only.
+ *
+ * @return completes with whether the TLS handshake with the client
succeeded
+ */
+ private CompletableFuture<Boolean> startServer() throws Exception {
+ KeyStore keyStore = KeyStore.getInstance("PKCS12");
+ try (InputStream is =
getClass().getClassLoader().getResourceAsStream(RESOURCES + "server.p12")) {
+ keyStore.load(is, PASSWORD.toCharArray());
+ }
+ KeyManagerFactory kmf =
KeyManagerFactory.getInstance(KeyManagerFactory.getDefaultAlgorithm());
+ kmf.init(keyStore, PASSWORD.toCharArray());
+ SSLContext sslContext = SSLContext.getInstance("TLS");
+ sslContext.init(kmf.getKeyManagers(), null, null);
+
+ server = new ServerSocket();
+ // localhost may connect to ::1 or 127.0.0.1
+ server.bind(new InetSocketAddress(0));
+ server.setSoTimeout((int) TimeUnit.SECONDS.toMillis(TIMEOUT_SECONDS));
+
+ CompletableFuture<Boolean> handshake = new CompletableFuture<>();
+ executor.submit(() -> {
+ try (Socket socket = server.accept()) {
+ socket.getOutputStream().write(("INFO
{\"server_id\":\"test\",\"version\":\"2.10.0\",\"proto\":1,"
+ +
"\"max_payload\":1048576,\"tls_required\":true}\r\n")
+ .getBytes(StandardCharsets.US_ASCII));
+ socket.getOutputStream().flush();
+ SSLSocket tls = (SSLSocket) sslContext.getSocketFactory()
+ .createSocket(socket, null, socket.getPort(), false);
+ tls.setUseClientMode(false);
+ try {
+ tls.startHandshake();
+ handshake.complete(true);
+ } catch (IOException e) {
+ handshake.complete(false);
+ }
+ } catch (Exception e) {
+ handshake.completeExceptionally(e);
+ }
+ });
+ return handshake;
+ }
+}
diff --git
a/components/camel-nats/src/test/resources/org/apache/camel/component/nats/hostname/server.p12
b/components/camel-nats/src/test/resources/org/apache/camel/component/nats/hostname/server.p12
new file mode 100644
index 000000000000..60d8433db995
Binary files /dev/null and
b/components/camel-nats/src/test/resources/org/apache/camel/component/nats/hostname/server.p12
differ
diff --git
a/components/camel-nats/src/test/resources/org/apache/camel/component/nats/hostname/truststore.p12
b/components/camel-nats/src/test/resources/org/apache/camel/component/nats/hostname/truststore.p12
new file mode 100644
index 000000000000..2705f7f17b5d
Binary files /dev/null and
b/components/camel-nats/src/test/resources/org/apache/camel/component/nats/hostname/truststore.p12
differ
diff --git
a/core/camel-util/src/main/java/org/apache/camel/util/SecurityUtils.java
b/core/camel-util/src/main/java/org/apache/camel/util/SecurityUtils.java
index ffd1a1dc60fb..189a91f0258a 100644
--- a/core/camel-util/src/main/java/org/apache/camel/util/SecurityUtils.java
+++ b/core/camel-util/src/main/java/org/apache/camel/util/SecurityUtils.java
@@ -185,6 +185,7 @@ public final class SecurityUtils {
"component:ftps",
"component:mina",
"component:mllp",
+ "component:nats",
"component:netty",
"component:nettyhttp",
"component:smpp",
diff --git
a/docs/user-manual/modules/ROOT/pages/camel-4x-upgrade-guide-4_24.adoc
b/docs/user-manual/modules/ROOT/pages/camel-4x-upgrade-guide-4_24.adoc
index d552fbdb2309..d09cb3e5af41 100644
--- a/docs/user-manual/modules/ROOT/pages/camel-4x-upgrade-guide-4_24.adoc
+++ b/docs/user-manual/modules/ROOT/pages/camel-4x-upgrade-guide-4_24.adoc
@@ -10022,3 +10022,24 @@ an empty value counts as unset.
The `region` option is no longer marked as required in the catalog, since
`region` or `endpoint` is required and the
`kmsClient` option replaces both. The producer still fails with "Region or
endpoint is required" when it has to create
a client and neither is set.
+
+=== camel-nats - the host name of the server is verified over TLS
+
+When the connection uses TLS (`secure=true`, or a `tls://` server address),
camel-nats now checks that the certificate
+of the NATS server matches the host it connects to, with the same rules as an
HTTPS client. Before, any certificate
+trusted by the trust store was accepted, whatever host the certificate was
issued for. To keep the host name for TLS,
+the client connects to the fastest of the IP addresses of a host name (the
happy eyeballs mode of jnats), instead of
+replacing the host name by its IP addresses first.
+
+A connection to a host name or an IP address that the certificate does not
list now fails the TLS handshake; an IP
+address must be listed as a subject alternative name of the certificate. This
also applies to the servers that the
+NATS cluster announces, which are often IP addresses.
+
+WARNING: The servers announced by the cluster are used only when the client
reconnects, so a certificate without the
+IP addresses that the cluster announces still connects at startup, and fails
only when the client fails over to
+another server. Before upgrading, check that the certificate of each server
lists the host names or IP addresses that
+the cluster announces (the `connect_urls` in the `INFO` of the servers, set
with their `client_advertise` option).
+
+Use certificates that match the hosts, or set the new `hostnameVerification`
option to `false` to keep the previous
+behaviour. An `opentls://` server address still trusts
+any certificate and is not checked.
diff --git
a/dsl/camel-componentdsl/src/generated/java/org/apache/camel/builder/component/dsl/NatsComponentBuilderFactory.java
b/dsl/camel-componentdsl/src/generated/java/org/apache/camel/builder/component/dsl/NatsComponentBuilderFactory.java
index 9a0650dca5c3..667a6fdb6165 100644
---
a/dsl/camel-componentdsl/src/generated/java/org/apache/camel/builder/component/dsl/NatsComponentBuilderFactory.java
+++
b/dsl/camel-componentdsl/src/generated/java/org/apache/camel/builder/component/dsl/NatsComponentBuilderFactory.java
@@ -811,6 +811,29 @@ public interface NatsComponentBuilderFactory {
}
+ /**
+ * Whether to check that the certificate of the NATS server matches the
+ * host Camel connects to, when TLS is used. The client then keeps the
+ * host name of a server for TLS, and connects to the fastest of its IP
+ * addresses. A server that is given, or that the cluster announces, by
+ * its IP address needs a certificate that names that address. When
+ * disabled, any certificate trusted by the JVM, or by the
+ * sslContextParameters, is accepted, whatever host it was issued for.
+ *
+ * The option is a: <code>boolean</code> type.
+ *
+ * Default: true
+ * Group: security
+ *
+ * @param hostnameVerification the value to set
+ * @return the dsl builder
+ */
+ default NatsComponentBuilder hostnameVerification(boolean
hostnameVerification) {
+ doSetProperty("hostnameVerification", hostnameVerification);
+ return this;
+ }
+
+
/**
* Set secure option indicating TLS is required.
*
@@ -921,6 +944,7 @@ public interface NatsComponentBuilderFactory {
case "jetstreamAsync": getOrCreateConfiguration((NatsComponent)
component).setJetstreamAsync((boolean) value); return true;
case "traceConnection": getOrCreateConfiguration((NatsComponent)
component).setTraceConnection((boolean) value); return true;
case "credentialsFilePath":
getOrCreateConfiguration((NatsComponent)
component).setCredentialsFilePath((java.lang.String) value); return true;
+ case "hostnameVerification":
getOrCreateConfiguration((NatsComponent)
component).setHostnameVerification((boolean) value); return true;
case "secure": getOrCreateConfiguration((NatsComponent)
component).setSecure((boolean) value); return true;
case "sslContextParameters":
getOrCreateConfiguration((NatsComponent)
component).setSslContextParameters((org.apache.camel.support.jsse.SSLContextParameters)
value); return true;
case "useGlobalSslContextParameters": ((NatsComponent)
component).setUseGlobalSslContextParameters((boolean) value); return true;
diff --git
a/dsl/camel-endpointdsl/src/generated/java/org/apache/camel/builder/endpoint/dsl/NatsEndpointBuilderFactory.java
b/dsl/camel-endpointdsl/src/generated/java/org/apache/camel/builder/endpoint/dsl/NatsEndpointBuilderFactory.java
index 60c62c77a0db..d800ff6f1786 100644
---
a/dsl/camel-endpointdsl/src/generated/java/org/apache/camel/builder/endpoint/dsl/NatsEndpointBuilderFactory.java
+++
b/dsl/camel-endpointdsl/src/generated/java/org/apache/camel/builder/endpoint/dsl/NatsEndpointBuilderFactory.java
@@ -941,6 +941,48 @@ public interface NatsEndpointBuilderFactory {
doSetProperty("credentialsFilePath", credentialsFilePath);
return this;
}
+ /**
+ * Whether to check that the certificate of the NATS server matches the
+ * host Camel connects to, when TLS is used. The client then keeps the
+ * host name of a server for TLS, and connects to the fastest of its IP
+ * addresses. A server that is given, or that the cluster announces, by
+ * its IP address needs a certificate that names that address. When
+ * disabled, any certificate trusted by the JVM, or by the
+ * sslContextParameters, is accepted, whatever host it was issued for.
+ *
+ * The option is a: <code>boolean</code> type.
+ *
+ * Default: true
+ * Group: security
+ *
+ * @param hostnameVerification the value to set
+ * @return the dsl builder
+ */
+ default NatsEndpointConsumerBuilder hostnameVerification(boolean
hostnameVerification) {
+ doSetProperty("hostnameVerification", hostnameVerification);
+ return this;
+ }
+ /**
+ * Whether to check that the certificate of the NATS server matches the
+ * host Camel connects to, when TLS is used. The client then keeps the
+ * host name of a server for TLS, and connects to the fastest of its IP
+ * addresses. A server that is given, or that the cluster announces, by
+ * its IP address needs a certificate that names that address. When
+ * disabled, any certificate trusted by the JVM, or by the
+ * sslContextParameters, is accepted, whatever host it was issued for.
+ *
+ * The option will be converted to a <code>boolean</code> type.
+ *
+ * Default: true
+ * Group: security
+ *
+ * @param hostnameVerification the value to set
+ * @return the dsl builder
+ */
+ default NatsEndpointConsumerBuilder hostnameVerification(String
hostnameVerification) {
+ doSetProperty("hostnameVerification", hostnameVerification);
+ return this;
+ }
/**
* Set secure option indicating TLS is required.
*
@@ -1822,6 +1864,48 @@ public interface NatsEndpointBuilderFactory {
doSetProperty("credentialsFilePath", credentialsFilePath);
return this;
}
+ /**
+ * Whether to check that the certificate of the NATS server matches the
+ * host Camel connects to, when TLS is used. The client then keeps the
+ * host name of a server for TLS, and connects to the fastest of its IP
+ * addresses. A server that is given, or that the cluster announces, by
+ * its IP address needs a certificate that names that address. When
+ * disabled, any certificate trusted by the JVM, or by the
+ * sslContextParameters, is accepted, whatever host it was issued for.
+ *
+ * The option is a: <code>boolean</code> type.
+ *
+ * Default: true
+ * Group: security
+ *
+ * @param hostnameVerification the value to set
+ * @return the dsl builder
+ */
+ default NatsEndpointProducerBuilder hostnameVerification(boolean
hostnameVerification) {
+ doSetProperty("hostnameVerification", hostnameVerification);
+ return this;
+ }
+ /**
+ * Whether to check that the certificate of the NATS server matches the
+ * host Camel connects to, when TLS is used. The client then keeps the
+ * host name of a server for TLS, and connects to the fastest of its IP
+ * addresses. A server that is given, or that the cluster announces, by
+ * its IP address needs a certificate that names that address. When
+ * disabled, any certificate trusted by the JVM, or by the
+ * sslContextParameters, is accepted, whatever host it was issued for.
+ *
+ * The option will be converted to a <code>boolean</code> type.
+ *
+ * Default: true
+ * Group: security
+ *
+ * @param hostnameVerification the value to set
+ * @return the dsl builder
+ */
+ default NatsEndpointProducerBuilder hostnameVerification(String
hostnameVerification) {
+ doSetProperty("hostnameVerification", hostnameVerification);
+ return this;
+ }
/**
* Set secure option indicating TLS is required.
*
@@ -2550,6 +2634,48 @@ public interface NatsEndpointBuilderFactory {
doSetProperty("credentialsFilePath", credentialsFilePath);
return this;
}
+ /**
+ * Whether to check that the certificate of the NATS server matches the
+ * host Camel connects to, when TLS is used. The client then keeps the
+ * host name of a server for TLS, and connects to the fastest of its IP
+ * addresses. A server that is given, or that the cluster announces, by
+ * its IP address needs a certificate that names that address. When
+ * disabled, any certificate trusted by the JVM, or by the
+ * sslContextParameters, is accepted, whatever host it was issued for.
+ *
+ * The option is a: <code>boolean</code> type.
+ *
+ * Default: true
+ * Group: security
+ *
+ * @param hostnameVerification the value to set
+ * @return the dsl builder
+ */
+ default NatsEndpointBuilder hostnameVerification(boolean
hostnameVerification) {
+ doSetProperty("hostnameVerification", hostnameVerification);
+ return this;
+ }
+ /**
+ * Whether to check that the certificate of the NATS server matches the
+ * host Camel connects to, when TLS is used. The client then keeps the
+ * host name of a server for TLS, and connects to the fastest of its IP
+ * addresses. A server that is given, or that the cluster announces, by
+ * its IP address needs a certificate that names that address. When
+ * disabled, any certificate trusted by the JVM, or by the
+ * sslContextParameters, is accepted, whatever host it was issued for.
+ *
+ * The option will be converted to a <code>boolean</code> type.
+ *
+ * Default: true
+ * Group: security
+ *
+ * @param hostnameVerification the value to set
+ * @return the dsl builder
+ */
+ default NatsEndpointBuilder hostnameVerification(String
hostnameVerification) {
+ doSetProperty("hostnameVerification", hostnameVerification);
+ return this;
+ }
/**
* Set secure option indicating TLS is required.
*