This is an automated email from the ASF dual-hosted git repository.
davsclaus pushed a commit to branch camel-4.22.x
in repository https://gitbox.apache.org/repos/asf/camel.git
The following commit(s) were added to refs/heads/camel-4.22.x by this push:
new ad04afe9b9e6 [backport camel-4.22.x] CAMEL-27206: camel-nats - check
the host name in the certificate of the NATS server when TLS is used (#30412)
ad04afe9b9e6 is described below
commit ad04afe9b9e6fc8ce3abec65039fe4b15a74d8f4
Author: Claus Ibsen <[email protected]>
AuthorDate: Thu Nov 19 14:10:33 2026 +0100
[backport camel-4.22.x] CAMEL-27206: camel-nats - check the host name in
the certificate of the NATS server when TLS is used (#30412)
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]>
(cherry picked from commit abf6f8aa83d5610a70613a37b46e7e1496a66a24)
---
.../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
.../component/dsl/NatsComponentBuilderFactory.java | 24 +++
.../endpoint/dsl/NatsEndpointBuilderFactory.java | 126 +++++++++++++++
13 files changed, 550 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 adc8d0d6b176..430e3e51ab73 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, "deprecationNote": "", "autowired":
false, "secret": false, "description": "The timestamp of a consumed message.",
"constantName":
"org.apache.camel.component.nats.NatsConstants#NATS_MESSAGE_TIMESTAMP" },
@@ -123,7 +124,8 @@
"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" }
}
}
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 b9f2658bec57..aaa28085db95 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
@@ -54,6 +54,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":
@@ -142,6 +144,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":
@@ -231,6 +235,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 162644fb2792..64bbe448f002 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
@@ -48,6 +48,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":
@@ -135,6 +137,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":
@@ -223,6 +227,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 d0bb129b5e73..2c157cbb51e9 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 adc8d0d6b176..430e3e51ab73 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, "deprecationNote": "", "autowired":
false, "secret": false, "description": "The timestamp of a consumed message.",
"constantName":
"org.apache.camel.component.nats.NatsConstants#NATS_MESSAGE_TIMESTAMP" },
@@ -123,7 +124,8 @@
"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" }
}
}
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 ed1aaa74511e..d10bfd2deaf5 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;
@@ -105,9 +107,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/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 e7a855382e1c..45eeab5cb778 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
@@ -812,6 +812,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.
*
@@ -922,6 +945,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 887a1152a30c..b74f90189b9c 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
@@ -943,6 +943,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.
*
@@ -1824,6 +1866,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.
*
@@ -2552,6 +2636,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.
*