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 779b3afe6be7 CAMEL-28012: camel-main, camel-spring-xml - Configure
endpointIdentificationAlgorithm with camel.ssl and in XML (#31220)
779b3afe6be7 is described below
commit 779b3afe6be720d8d50bf97c95f898ee889ab4a4
Author: Ayush Kulshreshtha <[email protected]>
AuthorDate: Wed Dec 2 17:57:51 2026 +0530
CAMEL-28012: camel-main, camel-spring-xml - Configure
endpointIdentificationAlgorithm with camel.ssl and in XML (#31220)
Co-Authored-By: Claude Opus 5.5 <[email protected]>
---
.../org/apache/camel/catalog/docs/main.adoc | 5 +-
.../main/camel-main-configuration-metadata.json | 3 +-
.../apache/camel/catalog/schemas/camel-spring.xsd | 1 +
.../SSLContextParametersFactoryBeanTest.java | 1 +
...SSLContextParametersFactoryBeanTest-context.xml | 3 +-
...tractSSLContextClientParametersFactoryBean.java | 19 ++++++
.../main/SSLConfigurationPropertiesConfigurer.java | 7 ++
.../camel-main-configuration-metadata.json | 3 +-
.../org/apache/camel/main/main-options.properties | 1 +
core/camel-main/src/main/docs/main.adoc | 5 +-
.../org/apache/camel/main/BaseMainSupport.java | 18 ++++-
.../camel/main/SSLConfigurationProperties.java | 39 +++++++++--
.../java/org/apache/camel/main/MainSSLTest.java | 78 ++++++++++++++++++++++
.../ROOT/pages/camel-configuration-utilities.adoc | 6 +-
14 files changed, 173 insertions(+), 16 deletions(-)
diff --git
a/catalog/camel-catalog/src/generated/resources/org/apache/camel/catalog/docs/main.adoc
b/catalog/camel-catalog/src/generated/resources/org/apache/camel/catalog/docs/main.adoc
index cac1d8baee84..08ace29d5bcd 100644
---
a/catalog/camel-catalog/src/generated/resources/org/apache/camel/catalog/docs/main.adoc
+++
b/catalog/camel-catalog/src/generated/resources/org/apache/camel/catalog/docs/main.adoc
@@ -369,7 +369,7 @@ The camel.security supports 6 options, which are listed
below.
=== Camel SSL configurations
-The camel.ssl supports 28 options, which are listed below.
+The camel.ssl supports 29 options, which are listed below.
[width="100%",cols="2,5,^1,2",options="header"]
|===
@@ -379,7 +379,8 @@ The camel.ssl supports 28 options, which are listed below.
| `camel.ssl.cipherSuitesExclude` | Regular expressions, separated by comma,
of the TLS cipher suite names to disable. Not used when cipherSuites is set. |
| String
| `camel.ssl.cipherSuitesInclude` | Regular expressions, separated by comma,
of the TLS cipher suite names to enable. Not used when cipherSuites is set. |
| String
| `camel.ssl.clientAuthentication` | Whether a server that uses the global SSL
configuration asks the client for a certificate: NONE (default) does not ask,
WANT asks but accepts a client without one, and REQUIRE rejects a client
without a valid certificate. | NONE | String
-| `camel.ssl.enabled` | Whether to create the global SSL configuration of the
CamelContext from the camel.ssl options. Components and the embedded HTTP
servers use it when their useGlobalSslContextParameters option is enabled. It
needs keyStore, selfSigned, trustStore or trustAllCertificates; when none is
set, a warning is logged and no SSL configuration is created. | false | boolean
+| `camel.ssl.enabled` | Whether to create the global SSL configuration of the
CamelContext from the camel.ssl options. Components and the embedded HTTP
servers use it when their useGlobalSslContextParameters option is enabled. It
needs keyStore, selfSigned, trustStore, trustAllCertificates or
endpointIdentificationAlgorithm; when none is set, a warning is logged and no
SSL configuration is created. | false | boolean
+| `camel.ssl.endpointIdentificationAlgorithm` | The endpoint identification
algorithm, such as HTTPS or LDAPS, that client sockets use to check that the
certificate of the server matches the host they connect to (host name
verification). Unset by default, in which case the TLS layer does not check the
host name; components such as camel-http may still verify it on their own.
Connecting to an IP address fails the handshake unless the certificate lists
that address. It is a client side opt [...]
| `camel.ssl.keyManagerAlgorithm` | The algorithm of the KeyManagerFactory,
such as PKIX or SunX509. When not set, the default of the JVM
(KeyManagerFactory.getDefaultAlgorithm()) is used. See
\https://docs.oracle.com/en/java/javase/21/docs/specs/security/standard-names.html
| | String
| `camel.ssl.keyManagerProvider` | The name of the security provider used to
create the KeyManagerFactory, one of java.security.Security.getProviders().
When not set, the highest-priority provider that supports the key manager
algorithm is used. | | String
| `camel.ssl.keyStore` | The key store with the private key and certificate of
this application, as a resource: classpath:name (the default when there is no
prefix), file:name, http:url, or ref:name to use a KeyStore bean from the
registry. | | String
diff --git
a/catalog/camel-catalog/src/generated/resources/org/apache/camel/catalog/main/camel-main-configuration-metadata.json
b/catalog/camel-catalog/src/generated/resources/org/apache/camel/catalog/main/camel-main-configuration-metadata.json
index adfc0732db73..5fe541dee5c3 100644
---
a/catalog/camel-catalog/src/generated/resources/org/apache/camel/catalog/main/camel-main-configuration-metadata.json
+++
b/catalog/camel-catalog/src/generated/resources/org/apache/camel/catalog/main/camel-main-configuration-metadata.json
@@ -519,7 +519,8 @@
{ "name": "camel.ssl.cipherSuitesExclude", "required": false,
"description": "Regular expressions, separated by comma, of the TLS cipher
suite names to disable. Not used when cipherSuites is set.", "sourceType":
"org.apache.camel.main.SSLConfigurationProperties", "type": "string",
"javaType": "java.lang.String", "secret": false },
{ "name": "camel.ssl.cipherSuitesInclude", "required": false,
"description": "Regular expressions, separated by comma, of the TLS cipher
suite names to enable. Not used when cipherSuites is set.", "sourceType":
"org.apache.camel.main.SSLConfigurationProperties", "type": "string",
"javaType": "java.lang.String", "secret": false },
{ "name": "camel.ssl.clientAuthentication", "required": false,
"description": "Whether a server that uses the global SSL configuration asks
the client for a certificate: NONE (default) does not ask, WANT asks but
accepts a client without one, and REQUIRE rejects a client without a valid
certificate.", "sourceType":
"org.apache.camel.main.SSLConfigurationProperties", "type": "enum", "javaType":
"java.lang.String", "defaultValue": "NONE", "secret": false, "enum": [ "NONE",
"WANT", "REQ [...]
- { "name": "camel.ssl.enabled", "required": false, "description": "Whether
to create the global SSL configuration of the CamelContext from the camel.ssl
options. Components and the embedded HTTP servers use it when their
useGlobalSslContextParameters option is enabled. It needs keyStore, selfSigned,
trustStore or trustAllCertificates; when none is set, a warning is logged and
no SSL configuration is created.", "sourceType":
"org.apache.camel.main.SSLConfigurationProperties", "type": " [...]
+ { "name": "camel.ssl.enabled", "required": false, "description": "Whether
to create the global SSL configuration of the CamelContext from the camel.ssl
options. Components and the embedded HTTP servers use it when their
useGlobalSslContextParameters option is enabled. It needs keyStore, selfSigned,
trustStore, trustAllCertificates or endpointIdentificationAlgorithm; when none
is set, a warning is logged and no SSL configuration is created.",
"sourceType": "org.apache.camel.main.SSLCo [...]
+ { "name": "camel.ssl.endpointIdentificationAlgorithm", "required": false,
"description": "The endpoint identification algorithm, such as HTTPS or LDAPS,
that client sockets use to check that the certificate of the server matches the
host they connect to (host name verification). Unset by default, in which case
the TLS layer does not check the host name; components such as camel-http may
still verify it on their own. Connecting to an IP address fails the handshake
unless the certifica [...]
{ "name": "camel.ssl.keyManagerAlgorithm", "required": false,
"description": "The algorithm of the KeyManagerFactory, such as PKIX or
SunX509. When not set, the default of the JVM
(KeyManagerFactory.getDefaultAlgorithm()) is used. See
https:\/\/docs.oracle.com\/en\/java\/javase\/21\/docs\/specs\/security\/standard-names.html",
"sourceType": "org.apache.camel.main.SSLConfigurationProperties", "type":
"string", "javaType": "java.lang.String", "secret": false },
{ "name": "camel.ssl.keyManagerProvider", "required": false,
"description": "The name of the security provider used to create the
KeyManagerFactory, one of java.security.Security.getProviders(). When not set,
the highest-priority provider that supports the key manager algorithm is
used.", "sourceType": "org.apache.camel.main.SSLConfigurationProperties",
"type": "string", "javaType": "java.lang.String", "secret": false },
{ "name": "camel.ssl.keyStore", "required": false, "description": "The key
store with the private key and certificate of this application, as a resource:
classpath:name (the default when there is no prefix), file:name, http:url, or
ref:name to use a KeyStore bean from the registry.", "sourceType":
"org.apache.camel.main.SSLConfigurationProperties", "type": "string",
"javaType": "java.lang.String", "secret": false },
diff --git
a/catalog/camel-catalog/src/generated/resources/org/apache/camel/catalog/schemas/camel-spring.xsd
b/catalog/camel-catalog/src/generated/resources/org/apache/camel/catalog/schemas/camel-spring.xsd
index c8be2f34a644..84f1018a07b4 100644
---
a/catalog/camel-catalog/src/generated/resources/org/apache/camel/catalog/schemas/camel-spring.xsd
+++
b/catalog/camel-catalog/src/generated/resources/org/apache/camel/catalog/schemas/camel-spring.xsd
@@ -17728,6 +17728,7 @@ Deprecated: .
<xs:element minOccurs="0" name="sniHostNames"
type="tns:sniHostNames"/>
</xs:all>
<xs:attribute name="sessionTimeout" type="xs:string"/>
+ <xs:attribute name="endpointIdentificationAlgorithm" type="xs:string"/>
</xs:extension>
</xs:complexContent>
</xs:complexType>
diff --git
a/components/camel-spring-parent/camel-spring-xml/src/test/java/org/apache/camel/util/spring/SSLContextParametersFactoryBeanTest.java
b/components/camel-spring-parent/camel-spring-xml/src/test/java/org/apache/camel/util/spring/SSLContextParametersFactoryBeanTest.java
index d4a80eebcd9a..d47b4c43a45f 100644
---
a/components/camel-spring-parent/camel-spring-xml/src/test/java/org/apache/camel/util/spring/SSLContextParametersFactoryBeanTest.java
+++
b/components/camel-spring-parent/camel-spring-xml/src/test/java/org/apache/camel/util/spring/SSLContextParametersFactoryBeanTest.java
@@ -66,6 +66,7 @@ public class SSLContextParametersFactoryBeanTest {
assertNotNull(scp.getClientParameters());
validateBaseSSLContextParameters(scp.getClientParameters());
+ assertEquals("HTTPS",
scp.getClientParameters().getEndpointIdentificationAlgorithm());
assertNotNull(scp.getServerParameters());
assertEquals(ClientAuthentication.WANT.name(),
scp.getServerParameters().getClientAuthentication());
diff --git
a/components/camel-spring-parent/camel-spring-xml/src/test/resources/org/apache/camel/util/spring/SSLContextParametersFactoryBeanTest-context.xml
b/components/camel-spring-parent/camel-spring-xml/src/test/resources/org/apache/camel/util/spring/SSLContextParametersFactoryBeanTest-context.xml
index 47e3c8ff1df3..413554ab3501 100644
---
a/components/camel-spring-parent/camel-spring-xml/src/test/resources/org/apache/camel/util/spring/SSLContextParametersFactoryBeanTest-context.xml
+++
b/components/camel-spring-parent/camel-spring-xml/src/test/resources/org/apache/camel/util/spring/SSLContextParametersFactoryBeanTest-context.xml
@@ -74,7 +74,8 @@
algorithm="algorithm"/>
<camel:clientParameters
- sessionTimeout="1">
+ sessionTimeout="1"
+ endpointIdentificationAlgorithm="HTTPS">
<camel:cipherSuites>
<camel:cipherSuite>cipherSuite</camel:cipherSuite>
</camel:cipherSuites>
diff --git
a/core/camel-core-xml/src/main/java/org/apache/camel/core/xml/util/jsse/AbstractSSLContextClientParametersFactoryBean.java
b/core/camel-core-xml/src/main/java/org/apache/camel/core/xml/util/jsse/AbstractSSLContextClientParametersFactoryBean.java
index 3536d7e5d335..bc1aef8f2cd3 100644
---
a/core/camel-core-xml/src/main/java/org/apache/camel/core/xml/util/jsse/AbstractSSLContextClientParametersFactoryBean.java
+++
b/core/camel-core-xml/src/main/java/org/apache/camel/core/xml/util/jsse/AbstractSSLContextClientParametersFactoryBean.java
@@ -18,10 +18,12 @@ package org.apache.camel.core.xml.util.jsse;
import jakarta.xml.bind.annotation.XmlAccessType;
import jakarta.xml.bind.annotation.XmlAccessorType;
+import jakarta.xml.bind.annotation.XmlAttribute;
import jakarta.xml.bind.annotation.XmlElement;
import jakarta.xml.bind.annotation.XmlTransient;
import org.apache.camel.CamelContextAware;
+import org.apache.camel.spi.Metadata;
import org.apache.camel.support.jsse.SSLContextClientParameters;
@XmlAccessorType(XmlAccessType.FIELD)
@@ -32,6 +34,14 @@ public abstract class
AbstractSSLContextClientParametersFactoryBean
@XmlElement(name = "sniHostNames")
private SNIHostNamesDefinition sniHostNamesDefinition;
+ @XmlAttribute
+ @Metadata(description = "The endpoint identification algorithm, such as
HTTPS or LDAPS, that client sockets use to"
+ + " check that the certificate of the server
matches the host they connect to (host name"
+ + " verification). Unset by default, in which case
the TLS layer does not check the host"
+ + " name; components such as camel-http may still
verify it on their own. Connecting to an"
+ + " IP address fails the handshake unless the
certificate lists that address.")
+ private String endpointIdentificationAlgorithm;
+
@Override
protected SSLContextClientParameters createInstance() {
SSLContextClientParameters newInstance = new
SSLContextClientParameters();
@@ -39,6 +49,7 @@ public abstract class
AbstractSSLContextClientParametersFactoryBean
if (sniHostNamesDefinition != null) {
newInstance.addAllSniHostNames(sniHostNamesDefinition.getSniHostName());
}
+
newInstance.setEndpointIdentificationAlgorithm(endpointIdentificationAlgorithm);
return newInstance;
}
@@ -50,4 +61,12 @@ public abstract class
AbstractSSLContextClientParametersFactoryBean
public SNIHostNamesDefinition getSniHostNamesDefinition() {
return sniHostNamesDefinition;
}
+
+ public String getEndpointIdentificationAlgorithm() {
+ return endpointIdentificationAlgorithm;
+ }
+
+ public void setEndpointIdentificationAlgorithm(String
endpointIdentificationAlgorithm) {
+ this.endpointIdentificationAlgorithm = endpointIdentificationAlgorithm;
+ }
}
diff --git
a/core/camel-main/src/generated/java/org/apache/camel/main/SSLConfigurationPropertiesConfigurer.java
b/core/camel-main/src/generated/java/org/apache/camel/main/SSLConfigurationPropertiesConfigurer.java
index 3d34da053fa5..7ae7e50ed51f 100644
---
a/core/camel-main/src/generated/java/org/apache/camel/main/SSLConfigurationPropertiesConfigurer.java
+++
b/core/camel-main/src/generated/java/org/apache/camel/main/SSLConfigurationPropertiesConfigurer.java
@@ -29,6 +29,7 @@ public class SSLConfigurationPropertiesConfigurer extends
org.apache.camel.suppo
map.put("CipherSuitesInclude", java.lang.String.class);
map.put("ClientAuthentication", java.lang.String.class);
map.put("Enabled", boolean.class);
+ map.put("EndpointIdentificationAlgorithm", java.lang.String.class);
map.put("KeyManagerAlgorithm", java.lang.String.class);
map.put("KeyManagerProvider", java.lang.String.class);
map.put("KeyStore", java.lang.String.class);
@@ -69,6 +70,8 @@ public class SSLConfigurationPropertiesConfigurer extends
org.apache.camel.suppo
case "clientauthentication":
case "clientAuthentication":
target.setClientAuthentication(property(camelContext, java.lang.String.class,
value)); return true;
case "enabled": target.setEnabled(property(camelContext,
boolean.class, value)); return true;
+ case "endpointidentificationalgorithm":
+ case "endpointIdentificationAlgorithm":
target.setEndpointIdentificationAlgorithm(property(camelContext,
java.lang.String.class, value)); return true;
case "keymanageralgorithm":
case "keyManagerAlgorithm":
target.setKeyManagerAlgorithm(property(camelContext, java.lang.String.class,
value)); return true;
case "keymanagerprovider":
@@ -135,6 +138,8 @@ public class SSLConfigurationPropertiesConfigurer extends
org.apache.camel.suppo
case "clientauthentication":
case "clientAuthentication": return java.lang.String.class;
case "enabled": return boolean.class;
+ case "endpointidentificationalgorithm":
+ case "endpointIdentificationAlgorithm": return java.lang.String.class;
case "keymanageralgorithm":
case "keyManagerAlgorithm": return java.lang.String.class;
case "keymanagerprovider":
@@ -197,6 +202,8 @@ public class SSLConfigurationPropertiesConfigurer extends
org.apache.camel.suppo
case "clientauthentication":
case "clientAuthentication": return target.getClientAuthentication();
case "enabled": return target.isEnabled();
+ case "endpointidentificationalgorithm":
+ case "endpointIdentificationAlgorithm": return
target.getEndpointIdentificationAlgorithm();
case "keymanageralgorithm":
case "keyManagerAlgorithm": return target.getKeyManagerAlgorithm();
case "keymanagerprovider":
diff --git
a/core/camel-main/src/generated/resources/META-INF/camel-main-configuration-metadata.json
b/core/camel-main/src/generated/resources/META-INF/camel-main-configuration-metadata.json
index adfc0732db73..5fe541dee5c3 100644
---
a/core/camel-main/src/generated/resources/META-INF/camel-main-configuration-metadata.json
+++
b/core/camel-main/src/generated/resources/META-INF/camel-main-configuration-metadata.json
@@ -519,7 +519,8 @@
{ "name": "camel.ssl.cipherSuitesExclude", "required": false,
"description": "Regular expressions, separated by comma, of the TLS cipher
suite names to disable. Not used when cipherSuites is set.", "sourceType":
"org.apache.camel.main.SSLConfigurationProperties", "type": "string",
"javaType": "java.lang.String", "secret": false },
{ "name": "camel.ssl.cipherSuitesInclude", "required": false,
"description": "Regular expressions, separated by comma, of the TLS cipher
suite names to enable. Not used when cipherSuites is set.", "sourceType":
"org.apache.camel.main.SSLConfigurationProperties", "type": "string",
"javaType": "java.lang.String", "secret": false },
{ "name": "camel.ssl.clientAuthentication", "required": false,
"description": "Whether a server that uses the global SSL configuration asks
the client for a certificate: NONE (default) does not ask, WANT asks but
accepts a client without one, and REQUIRE rejects a client without a valid
certificate.", "sourceType":
"org.apache.camel.main.SSLConfigurationProperties", "type": "enum", "javaType":
"java.lang.String", "defaultValue": "NONE", "secret": false, "enum": [ "NONE",
"WANT", "REQ [...]
- { "name": "camel.ssl.enabled", "required": false, "description": "Whether
to create the global SSL configuration of the CamelContext from the camel.ssl
options. Components and the embedded HTTP servers use it when their
useGlobalSslContextParameters option is enabled. It needs keyStore, selfSigned,
trustStore or trustAllCertificates; when none is set, a warning is logged and
no SSL configuration is created.", "sourceType":
"org.apache.camel.main.SSLConfigurationProperties", "type": " [...]
+ { "name": "camel.ssl.enabled", "required": false, "description": "Whether
to create the global SSL configuration of the CamelContext from the camel.ssl
options. Components and the embedded HTTP servers use it when their
useGlobalSslContextParameters option is enabled. It needs keyStore, selfSigned,
trustStore, trustAllCertificates or endpointIdentificationAlgorithm; when none
is set, a warning is logged and no SSL configuration is created.",
"sourceType": "org.apache.camel.main.SSLCo [...]
+ { "name": "camel.ssl.endpointIdentificationAlgorithm", "required": false,
"description": "The endpoint identification algorithm, such as HTTPS or LDAPS,
that client sockets use to check that the certificate of the server matches the
host they connect to (host name verification). Unset by default, in which case
the TLS layer does not check the host name; components such as camel-http may
still verify it on their own. Connecting to an IP address fails the handshake
unless the certifica [...]
{ "name": "camel.ssl.keyManagerAlgorithm", "required": false,
"description": "The algorithm of the KeyManagerFactory, such as PKIX or
SunX509. When not set, the default of the JVM
(KeyManagerFactory.getDefaultAlgorithm()) is used. See
https:\/\/docs.oracle.com\/en\/java\/javase\/21\/docs\/specs\/security\/standard-names.html",
"sourceType": "org.apache.camel.main.SSLConfigurationProperties", "type":
"string", "javaType": "java.lang.String", "secret": false },
{ "name": "camel.ssl.keyManagerProvider", "required": false,
"description": "The name of the security provider used to create the
KeyManagerFactory, one of java.security.Security.getProviders(). When not set,
the highest-priority provider that supports the key manager algorithm is
used.", "sourceType": "org.apache.camel.main.SSLConfigurationProperties",
"type": "string", "javaType": "java.lang.String", "secret": false },
{ "name": "camel.ssl.keyStore", "required": false, "description": "The key
store with the private key and certificate of this application, as a resource:
classpath:name (the default when there is no prefix), file:name, http:url, or
ref:name to use a KeyStore bean from the registry.", "sourceType":
"org.apache.camel.main.SSLConfigurationProperties", "type": "string",
"javaType": "java.lang.String", "secret": false },
diff --git
a/core/camel-main/src/generated/resources/org/apache/camel/main/main-options.properties
b/core/camel-main/src/generated/resources/org/apache/camel/main/main-options.properties
index f1e79a30410f..e73cf5abb7a5 100644
---
a/core/camel-main/src/generated/resources/org/apache/camel/main/main-options.properties
+++
b/core/camel-main/src/generated/resources/org/apache/camel/main/main-options.properties
@@ -478,6 +478,7 @@ camel.ssl.cipherSuitesExclude
camel.ssl.cipherSuitesInclude
camel.ssl.clientAuthentication
camel.ssl.enabled
+camel.ssl.endpointIdentificationAlgorithm
camel.ssl.keyManagerAlgorithm
camel.ssl.keyManagerProvider
camel.ssl.keyStore
diff --git a/core/camel-main/src/main/docs/main.adoc
b/core/camel-main/src/main/docs/main.adoc
index cac1d8baee84..08ace29d5bcd 100644
--- a/core/camel-main/src/main/docs/main.adoc
+++ b/core/camel-main/src/main/docs/main.adoc
@@ -369,7 +369,7 @@ The camel.security supports 6 options, which are listed
below.
=== Camel SSL configurations
-The camel.ssl supports 28 options, which are listed below.
+The camel.ssl supports 29 options, which are listed below.
[width="100%",cols="2,5,^1,2",options="header"]
|===
@@ -379,7 +379,8 @@ The camel.ssl supports 28 options, which are listed below.
| `camel.ssl.cipherSuitesExclude` | Regular expressions, separated by comma,
of the TLS cipher suite names to disable. Not used when cipherSuites is set. |
| String
| `camel.ssl.cipherSuitesInclude` | Regular expressions, separated by comma,
of the TLS cipher suite names to enable. Not used when cipherSuites is set. |
| String
| `camel.ssl.clientAuthentication` | Whether a server that uses the global SSL
configuration asks the client for a certificate: NONE (default) does not ask,
WANT asks but accepts a client without one, and REQUIRE rejects a client
without a valid certificate. | NONE | String
-| `camel.ssl.enabled` | Whether to create the global SSL configuration of the
CamelContext from the camel.ssl options. Components and the embedded HTTP
servers use it when their useGlobalSslContextParameters option is enabled. It
needs keyStore, selfSigned, trustStore or trustAllCertificates; when none is
set, a warning is logged and no SSL configuration is created. | false | boolean
+| `camel.ssl.enabled` | Whether to create the global SSL configuration of the
CamelContext from the camel.ssl options. Components and the embedded HTTP
servers use it when their useGlobalSslContextParameters option is enabled. It
needs keyStore, selfSigned, trustStore, trustAllCertificates or
endpointIdentificationAlgorithm; when none is set, a warning is logged and no
SSL configuration is created. | false | boolean
+| `camel.ssl.endpointIdentificationAlgorithm` | The endpoint identification
algorithm, such as HTTPS or LDAPS, that client sockets use to check that the
certificate of the server matches the host they connect to (host name
verification). Unset by default, in which case the TLS layer does not check the
host name; components such as camel-http may still verify it on their own.
Connecting to an IP address fails the handshake unless the certificate lists
that address. It is a client side opt [...]
| `camel.ssl.keyManagerAlgorithm` | The algorithm of the KeyManagerFactory,
such as PKIX or SunX509. When not set, the default of the JVM
(KeyManagerFactory.getDefaultAlgorithm()) is used. See
\https://docs.oracle.com/en/java/javase/21/docs/specs/security/standard-names.html
| | String
| `camel.ssl.keyManagerProvider` | The name of the security provider used to
create the KeyManagerFactory, one of java.security.Security.getProviders().
When not set, the highest-priority provider that supports the key manager
algorithm is used. | | String
| `camel.ssl.keyStore` | The key store with the private key and certificate of
this application, as a resource: classpath:name (the default when there is no
prefix), file:name, http:url, or ref:name to use a KeyStore bean from the
registry. | | String
diff --git
a/core/camel-main/src/main/java/org/apache/camel/main/BaseMainSupport.java
b/core/camel-main/src/main/java/org/apache/camel/main/BaseMainSupport.java
index a4ad532598b1..c5161fc004e5 100644
--- a/core/camel-main/src/main/java/org/apache/camel/main/BaseMainSupport.java
+++ b/core/camel-main/src/main/java/org/apache/camel/main/BaseMainSupport.java
@@ -108,6 +108,7 @@ import org.apache.camel.support.jsse.FilterParameters;
import org.apache.camel.support.jsse.KeyManagersParameters;
import org.apache.camel.support.jsse.KeyStoreParameters;
import org.apache.camel.support.jsse.NamedGroupsParameters;
+import org.apache.camel.support.jsse.SSLContextClientParameters;
import org.apache.camel.support.jsse.SSLContextParameters;
import org.apache.camel.support.jsse.SSLContextServerParameters;
import org.apache.camel.support.jsse.SecureRandomParameters;
@@ -2544,11 +2545,13 @@ public abstract class BaseMainSupport extends
BaseService {
kmp.setCamelContext(camelContext);
kmp.setKeyPassword(password);
kmp.setKeyStore(ksp);
- } else if (sslConfig.getTrustStore() != null ||
sslConfig.isTrustAllCertificates()) {
- // client side only (no key store), such as trusting a private
certificate authority
+ } else if (sslConfig.getTrustStore() != null ||
sslConfig.isTrustAllCertificates()
+ || sslConfig.getEndpointIdentificationAlgorithm() != null) {
+ // client side only (no key store), such as trusting a private
certificate authority or verifying the host
+ // name of the server with the trust store of the JDK
kmp = null;
} else {
- LOG.warn("SSL is enabled but no keystore or truststore is
configured."
+ LOG.warn("SSL is enabled but no keystore, truststore or
endpointIdentificationAlgorithm is configured."
+ " Set camel.ssl.keyStore or camel.ssl.selfSigned=true
for development.");
return;
}
@@ -2586,6 +2589,14 @@ public abstract class BaseMainSupport extends
BaseService {
scsp.setCamelContext(camelContext);
scsp.setClientAuthentication(sslConfig.getClientAuthentication());
+ // client parameters only when needed, so that the default context is
configured as before
+ SSLContextClientParameters sccp = null;
+ if (sslConfig.getEndpointIdentificationAlgorithm() != null) {
+ sccp = new SSLContextClientParameters();
+ sccp.setCamelContext(camelContext);
+
sccp.setEndpointIdentificationAlgorithm(sslConfig.getEndpointIdentificationAlgorithm());
+ }
+
SecureRandomParameters srp = null;
if (sslConfig.getSecureRandomAlgorithm() != null ||
sslConfig.getSecureRandomProvider() != null) {
srp = new SecureRandomParameters();
@@ -2668,6 +2679,7 @@ public abstract class BaseMainSupport extends BaseService
{
sslContextParameters.setKeyManagers(kmp);
sslContextParameters.setTrustManagers(tmp);
sslContextParameters.setServerParameters(scsp);
+ sslContextParameters.setClientParameters(sccp);
sslContextParameters.setSecureRandom(srp);
return sslContextParameters;
}
diff --git
a/core/camel-main/src/main/java/org/apache/camel/main/SSLConfigurationProperties.java
b/core/camel-main/src/main/java/org/apache/camel/main/SSLConfigurationProperties.java
index 91ccaf7cfe41..24cc0de70310 100644
---
a/core/camel-main/src/main/java/org/apache/camel/main/SSLConfigurationProperties.java
+++
b/core/camel-main/src/main/java/org/apache/camel/main/SSLConfigurationProperties.java
@@ -84,6 +84,8 @@ public class SSLConfigurationProperties implements
BootstrapCloseable {
private String secureRandomProvider;
@Metadata(defaultValue = "NONE", enums = "NONE,WANT,REQUIRE")
private String clientAuthentication = "NONE";
+ @Metadata
+ private String endpointIdentificationAlgorithm;
public SSLConfigurationProperties(MainConfigurationProperties parent) {
this.parent = parent;
@@ -105,8 +107,8 @@ public class SSLConfigurationProperties implements
BootstrapCloseable {
/**
* Whether to create the global SSL configuration of the CamelContext from
the camel.ssl options. Components and the
* embedded HTTP servers use it when their useGlobalSslContextParameters
option is enabled. It needs keyStore,
- * selfSigned, trustStore or trustAllCertificates; when none is set, a
warning is logged and no SSL configuration is
- * created.
+ * selfSigned, trustStore, trustAllCertificates or
endpointIdentificationAlgorithm; when none is set, a warning is
+ * logged and no SSL configuration is created.
*/
public void setEnabled(boolean enabled) {
this.enabled = enabled;
@@ -446,11 +448,27 @@ public class SSLConfigurationProperties implements
BootstrapCloseable {
this.clientAuthentication = clientAuthentication;
}
+ public String getEndpointIdentificationAlgorithm() {
+ return endpointIdentificationAlgorithm;
+ }
+
+ /**
+ * The endpoint identification algorithm, such as HTTPS or LDAPS, that
client sockets use to check that the
+ * certificate of the server matches the host they connect to (host name
verification). Unset by default, in which
+ * case the TLS layer does not check the host name; components such as
camel-http may still verify it on their own.
+ * <p>
+ * Connecting to an IP address fails the handshake unless the certificate
lists that address. It is a client side
+ * option, so it is enough to create the global SSL configuration without
a key store, as trustStore is.
+ */
+ public void setEndpointIdentificationAlgorithm(String
endpointIdentificationAlgorithm) {
+ this.endpointIdentificationAlgorithm = endpointIdentificationAlgorithm;
+ }
+
/**
* Whether to create the global SSL configuration of the CamelContext from
the camel.ssl options. Components and the
* embedded HTTP servers use it when their useGlobalSslContextParameters
option is enabled. It needs keyStore,
- * selfSigned, trustStore or trustAllCertificates; when none is set, a
warning is logged and no SSL configuration is
- * created.
+ * selfSigned, trustStore, trustAllCertificates or
endpointIdentificationAlgorithm; when none is set, a warning is
+ * logged and no SSL configuration is created.
*/
public SSLConfigurationProperties withEnabled(boolean enabled) {
this.enabled = enabled;
@@ -710,4 +728,17 @@ public class SSLConfigurationProperties implements
BootstrapCloseable {
return this;
}
+ /**
+ * The endpoint identification algorithm, such as HTTPS or LDAPS, that
client sockets use to check that the
+ * certificate of the server matches the host they connect to (host name
verification). Unset by default, in which
+ * case the TLS layer does not check the host name; components such as
camel-http may still verify it on their own.
+ * <p>
+ * Connecting to an IP address fails the handshake unless the certificate
lists that address. It is a client side
+ * option, so it is enough to create the global SSL configuration without
a key store, as trustStore is.
+ */
+ public SSLConfigurationProperties
withEndpointIdentificationAlgorithm(String endpointIdentificationAlgorithm) {
+ this.endpointIdentificationAlgorithm = endpointIdentificationAlgorithm;
+ return this;
+ }
+
}
diff --git
a/core/camel-main/src/test/java/org/apache/camel/main/MainSSLTest.java
b/core/camel-main/src/test/java/org/apache/camel/main/MainSSLTest.java
index 8c80a3981f7f..f345fdb7ef2b 100644
--- a/core/camel-main/src/test/java/org/apache/camel/main/MainSSLTest.java
+++ b/core/camel-main/src/test/java/org/apache/camel/main/MainSSLTest.java
@@ -29,6 +29,7 @@ import org.apache.camel.support.jsse.FilterParameters;
import org.apache.camel.support.jsse.KeyManagersParameters;
import org.apache.camel.support.jsse.KeyStoreParameters;
import org.apache.camel.support.jsse.NamedGroupsParameters;
+import org.apache.camel.support.jsse.SSLContextClientParameters;
import org.apache.camel.support.jsse.SSLContextParameters;
import org.apache.camel.support.jsse.SSLContextServerParameters;
import org.apache.camel.support.jsse.SignatureSchemesParameters;
@@ -84,6 +85,8 @@ public class MainSSLTest {
Assertions.assertEquals(ClientAuthentication.REQUIRE.name(),
scsp.getClientAuthentication());
+ assertNull(sslParams.getClientParameters());
+
main.stop();
}
@@ -523,4 +526,79 @@ public class MainSSLTest {
main.stop();
}
+
+ @Test
+ public void testMainSSLEndpointIdentificationAlgorithm() {
+ Main main = new Main();
+
+ main.addInitialProperty("camel.ssl.enabled", "true");
+ main.addInitialProperty("camel.ssl.keyStore", "server.jks");
+ main.addInitialProperty("camel.ssl.keystorePassword", "security");
+ main.addInitialProperty("camel.ssl.endpointIdentificationAlgorithm",
"HTTPS");
+
+ main.start();
+
+ CamelContext context = main.getCamelContext();
+ assertNotNull(context);
+
+ SSLContextParameters sslParams = context.getSSLContextParameters();
+ assertNotNull(sslParams);
+
+ SSLContextClientParameters sccp = sslParams.getClientParameters();
+ assertNotNull(sccp);
+ Assertions.assertEquals("HTTPS",
sccp.getEndpointIdentificationAlgorithm());
+ Assertions.assertSame(context, sccp.getCamelContext());
+
+ main.stop();
+ }
+
+ @Test
+ public void testMainSSLEndpointIdentificationAlgorithmWithoutKeyStore() {
+ Main main = new Main();
+
+ // client side only: the trust store of the JDK, and host name
verification
+ main.addInitialProperty("camel.ssl.enabled", "true");
+ main.addInitialProperty("camel.ssl.endpointIdentificationAlgorithm",
"HTTPS");
+
+ main.start();
+
+ CamelContext context = main.getCamelContext();
+ assertNotNull(context);
+
+ SSLContextParameters sslParams = context.getSSLContextParameters();
+ assertNotNull(sslParams);
+ assertNull(sslParams.getKeyManagers());
+ assertNull(sslParams.getTrustManagers());
+
+ SSLContextClientParameters sccp = sslParams.getClientParameters();
+ assertNotNull(sccp);
+ Assertions.assertEquals("HTTPS",
sccp.getEndpointIdentificationAlgorithm());
+
+ main.stop();
+ }
+
+ @Test
+ public void testMainSSLEndpointIdentificationAlgorithmFluent() {
+ Main main = new Main();
+
+ main.configure().sslConfig()
+ .withEnabled(true)
+ .withKeyStore("server.jks")
+ .withKeystorePassword("security")
+ .withEndpointIdentificationAlgorithm("LDAPS");
+
+ main.start();
+
+ CamelContext context = main.getCamelContext();
+ assertNotNull(context);
+
+ SSLContextParameters sslParams = context.getSSLContextParameters();
+ assertNotNull(sslParams);
+
+ SSLContextClientParameters sccp = sslParams.getClientParameters();
+ assertNotNull(sccp);
+ Assertions.assertEquals("LDAPS",
sccp.getEndpointIdentificationAlgorithm());
+
+ main.stop();
+ }
}
diff --git
a/docs/user-manual/modules/ROOT/pages/camel-configuration-utilities.adoc
b/docs/user-manual/modules/ROOT/pages/camel-configuration-utilities.adoc
index 188f6b7a8e84..b5098735b517 100644
--- a/docs/user-manual/modules/ROOT/pages/camel-configuration-utilities.adoc
+++ b/docs/user-manual/modules/ROOT/pages/camel-configuration-utilities.adoc
@@ -349,7 +349,7 @@ SSLEngine configuration.
SSLContextClientParameters contains the following elements:
* sniHostNames (elements)
-* endpointIdentificationAlgorithm (Java API)
+* endpointIdentificationAlgorithm (attribute)
* sessionTimeout (attribute)
* cipherSuites (element)
* cipherSuitesFilter (element)
@@ -373,7 +373,9 @@ given to `connect`), so connecting by IP address fails the
handshake unless
the certificate lists that address. It is
not applied to an `SSLEngine`, which starts in server mode: a component
that uses an engine applies it to the `SSLParameters` of the engine once
-the engine is in client mode.
+the engine is in client mode. With Camel Main, the
+`camel.ssl.endpointIdentificationAlgorithm` option sets it on the client
+parameters of the global SSL configuration.
sessionTimeout::
See above
cipherSuites::