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 1452dfcb7e84 CAMEL-26546: camel-vertx, camel-kafka, camel-thrift -
apply or report the named groups and signature schemes of sslContextParameters
(#30891)
1452dfcb7e84 is described below
commit 1452dfcb7e843be6c8c75342d96fa0651b9f858a
Author: Claus Ibsen <[email protected]>
AuthorDate: Fri Nov 27 07:17:04 2026 +0100
CAMEL-26546: camel-vertx, camel-kafka, camel-thrift - apply or report the
named groups and signature schemes of sslContextParameters (#30891)
SSLContextParameters prefers the hybrid post-quantum named groups, but only
components that use the SSLContext of
createSSLContext() apply them. Components that hand the key and trust
material to a TLS stack of their own dropped
namedGroups and signatureSchemes without a word.
- camel-api: new JsseParametersHelper (engineOnlyParameters,
postQuantumNamedGroups) with the shared PQC ordering
of CAMEL-26545.
- camel-vertx-common (platform-http-vertx, vertx-http, vertx-websocket,
vertx-mqtt, apicurio-registry): the named
groups are applied as the Vert.x key exchange groups; a WARN when
signature schemes are configured, as Vert.x has
no setting for them.
- camel-kafka-common and the camel-thrift producer: a WARN when named
groups or signature schemes are configured,
the lost PQC preference only at DEBUG.
- camel-netty: SSLEngineFactory uses the shared ordering function.
- Docs: security.adoc, a "Components with their own TLS stack" table in the
JSSE utility page, component notes and a
4.24 upgrade guide entry.
Co-Authored-By: Claude Opus 5.5 <[email protected]>
---
.../apache/camel/catalog/docs/kafka-component.adoc | 7 +
.../camel/catalog/docs/thrift-component.adoc | 6 +
.../camel/catalog/docs/vertx-http-component.adoc | 4 +
.../catalog/docs/vertx-websocket-component.adoc | 5 +
.../component/kafka/KafkaClientConfiguration.java | 40 ++++
.../kafka/KafkaClientConfigurationSslTest.java | 138 +++++++++++
.../src/test/resources/log4j2.properties | 25 ++
.../camel-kafka/src/main/docs/kafka-component.adoc | 7 +
.../component/netty/ssl/SSLEngineFactory.java | 64 +-----
.../component/netty/SSLEngineFactoryTest.java | 34 +++
.../src/main/docs/thrift-component.adoc | 6 +
.../camel/component/thrift/ThriftProducer.java | 26 +++
.../thrift/ThriftProducerSslOptionsTest.java | 155 +++++++++++++
.../camel/component/vertx/common/VertxHelper.java | 58 ++++-
.../vertx/common/VertxHelperNamedGroupsTest.java | 256 +++++++++++++++++++++
.../src/test/resources/jsse/service.jks | Bin 0 -> 1969 bytes
.../src/test/resources/log4j2.properties | 25 ++
.../src/main/docs/vertx-http-component.adoc | 4 +
.../src/main/docs/vertx-websocket-component.adoc | 5 +
.../camel/support/jsse/JsseParametersHelper.java | 115 +++++++++
.../support/jsse/JsseParametersHelperTest.java | 109 +++++++++
.../ROOT/pages/camel-4x-upgrade-guide-4_24.adoc | 16 ++
.../ROOT/pages/camel-configuration-utilities.adoc | 40 +++-
docs/user-manual/modules/ROOT/pages/security.adoc | 12 +-
24 files changed, 1092 insertions(+), 65 deletions(-)
diff --git
a/catalog/camel-catalog/src/generated/resources/org/apache/camel/catalog/docs/kafka-component.adoc
b/catalog/camel-catalog/src/generated/resources/org/apache/camel/catalog/docs/kafka-component.adoc
index 247e1c977402..c0faf32bc841 100644
---
a/catalog/camel-catalog/src/generated/resources/org/apache/camel/catalog/docs/kafka-component.adoc
+++
b/catalog/camel-catalog/src/generated/resources/org/apache/camel/catalog/docs/kafka-component.adoc
@@ -2176,3 +2176,10 @@ YAML::
uri: mock:result
----
====
+
+The Kafka client creates its TLS connections from its `ssl.*` properties,
which the `sslContextParameters` are mapped
+to: the protocol, the provider, the cipher suites, the enabled protocols and
the key and trust stores. The Kafka client
+has no properties for the named groups and the signature schemes, so these are
not applied: a `WARN` is logged when
+they are configured, and the client uses the named groups of the JVM, also for
the post-quantum preference that
+`SSLContextParameters` applies elsewhere. See _Components with their own TLS
stack_ in the xref:manual::camel-configuration-utilities.adoc[Camel JSSE
Configuration Utility] for
+setting them for the whole JVM instead.
diff --git
a/catalog/camel-catalog/src/generated/resources/org/apache/camel/catalog/docs/thrift-component.adoc
b/catalog/camel-catalog/src/generated/resources/org/apache/camel/catalog/docs/thrift-component.adoc
index 9337cd0cf62f..df4dbc8bff33 100644
---
a/catalog/camel-catalog/src/generated/resources/org/apache/camel/catalog/docs/thrift-component.adoc
+++
b/catalog/camel-catalog/src/generated/resources/org/apache/camel/catalog/docs/thrift-component.adoc
@@ -194,6 +194,12 @@
from("thrift://0.0.0.0:1101/org.apache.camel.component.thrift.generated.Calculat
.to("direct:thrift-service");
----
+The producer creates its TLS connection with the Thrift
`TSSLTransportFactory`, from the secure socket protocol, the
+cipher suites and the trust store of `sslParameters` only. The named groups
and the signature schemes are not applied
+by the producer, and a `WARN` is logged when they are configured. The producer
uses the named groups of the JVM, also
+for the post-quantum preference that `SSLContextParameters` applies elsewhere.
See _Components with their own TLS
+stack_ in the xref:manual::camel-configuration-utilities.adoc[Camel JSSE
Configuration Utility].
+
== Errors sent to the client
When the exchange of a consumer fails, the Thrift client receives an error. An
exception that the Thrift method
diff --git
a/catalog/camel-catalog/src/generated/resources/org/apache/camel/catalog/docs/vertx-http-component.adoc
b/catalog/camel-catalog/src/generated/resources/org/apache/camel/catalog/docs/vertx-http-component.adoc
index 39655215ce68..bfaa1bf2c790 100644
---
a/catalog/camel-catalog/src/generated/resources/org/apache/camel/catalog/docs/vertx-http-component.adoc
+++
b/catalog/camel-catalog/src/generated/resources/org/apache/camel/catalog/docs/vertx-http-component.adoc
@@ -217,6 +217,10 @@ It is also possible to configure SSL options by providing
a custom `WebClientOpt
An `https://` address is always called with TLS. When no
`sslContextParameters` is configured, the server certificate
is checked with the default trust store of the JVM.
+Vert.x creates its own TLS engine from the `sslContextParameters`: the key and
trust managers, the cipher suites, the
+protocols and the named groups (including the post-quantum preference of
`SSLContextParameters`) are applied. Vert.x has
+no setting for the signature schemes, which are not applied, and a `WARN` is
logged when they are configured.
+
=== Session Management
Session management can be enabled via the `sessionManagement` URI option. When
enabled, an in-memory cookie store is used to track cookies.
diff --git
a/catalog/camel-catalog/src/generated/resources/org/apache/camel/catalog/docs/vertx-websocket-component.adoc
b/catalog/camel-catalog/src/generated/resources/org/apache/camel/catalog/docs/vertx-websocket-component.adoc
index 477be310f3bd..7c83b54afbac 100644
---
a/catalog/camel-catalog/src/generated/resources/org/apache/camel/catalog/docs/vertx-websocket-component.adoc
+++
b/catalog/camel-catalog/src/generated/resources/org/apache/camel/catalog/docs/vertx-websocket-component.adoc
@@ -373,3 +373,8 @@ via the `sslContextParameters` URI parameter and the
xref:manual::camel-configur
All consumers on the same host and port are served by one HTTP server, so they
must use the same `sslContextParameters`
instance. A consumer whose `sslContextParameters` differ from those of the
consumers already started on its host and
port fails to start.
+
+Vert.x creates its own TLS engine from the `sslContextParameters`: the key and
trust managers, the client
+authentication, the cipher suites, the protocols and the named groups
(including the post-quantum preference of
+`SSLContextParameters`) are applied. Vert.x has no setting for the signature
schemes, which are not applied, and a
+`WARN` is logged when they are configured.
diff --git
a/components/camel-kafka-common/src/main/java/org/apache/camel/component/kafka/KafkaClientConfiguration.java
b/components/camel-kafka-common/src/main/java/org/apache/camel/component/kafka/KafkaClientConfiguration.java
index 5623f2e46694..fa7b69f8a20d 100644
---
a/components/camel-kafka-common/src/main/java/org/apache/camel/component/kafka/KafkaClientConfiguration.java
+++
b/components/camel-kafka-common/src/main/java/org/apache/camel/component/kafka/KafkaClientConfiguration.java
@@ -35,6 +35,7 @@ import org.apache.camel.spi.UriParam;
import org.apache.camel.spi.UriParams;
import org.apache.camel.support.ResourceHelper;
import org.apache.camel.support.jsse.CipherSuitesParameters;
+import org.apache.camel.support.jsse.JsseParametersHelper;
import org.apache.camel.support.jsse.KeyManagersParameters;
import org.apache.camel.support.jsse.KeyStoreParameters;
import org.apache.camel.support.jsse.SSLContextParameters;
@@ -48,6 +49,8 @@ import org.apache.kafka.common.config.SaslConfigs;
import org.apache.kafka.common.config.SslConfigs;
import org.apache.kafka.common.config.internals.BrokerSecurityConfigs;
import org.apache.kafka.common.security.auth.SecurityProtocol;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
/**
* Base configuration of the Camel Kafka endpoints: the brokers, the client
id, the connection, metrics and backoff
@@ -63,6 +66,14 @@ import
org.apache.kafka.common.security.auth.SecurityProtocol;
@UriParams
public abstract class KafkaClientConfiguration implements Cloneable,
HeaderFilterStrategyAware {
+ private static final Logger LOG =
LoggerFactory.getLogger(KafkaClientConfiguration.class);
+
+ /**
+ * Whether the options of sslContextParameters that the Kafka client
cannot carry have been logged, so it is done
+ * once per endpoint, not each time the properties of a Kafka client are
created.
+ */
+ private volatile boolean droppedSslOptionsLogged;
+
@UriParam(label = "common",
description = "URL of the Kafka brokers to use. The format is
host1:port1,host2:port2, and the list can be a "
+ "subset of brokers or a VIP pointing to a subset
of brokers. This option is known as "
@@ -400,6 +411,7 @@ public abstract class KafkaClientConfiguration implements
Cloneable, HeaderFilte
try {
KafkaClientConfiguration copy = (KafkaClientConfiguration) clone();
copy.additionalProperties = new
HashMap<>(this.additionalProperties);
+ copy.droppedSslOptionsLogged = false;
return copy;
} catch (CloneNotSupportedException e) {
throw new RuntimeCamelException(e);
@@ -547,6 +559,7 @@ public abstract class KafkaClientConfiguration implements
Cloneable, HeaderFilte
String protocol = resolveSecurityProtocol();
if (sslContextParameters != null) {
applySslConfigurationFromContext(props, sslContextParameters);
+ logDroppedSslOptions(sslContextParameters);
}
applySslConfigurationFromOptions(props, protocol);
@@ -643,6 +656,33 @@ public abstract class KafkaClientConfiguration implements
Cloneable, HeaderFilte
}
}
+ /**
+ * The Kafka client builds its TLS connections from the ssl.* properties,
which cannot carry the options that only
+ * the SSLContext of {@code SSLContextParameters.createSSLContext}
applies: say so once instead of dropping them in
+ * silence. The post-quantum preference of the named groups, which that
SSLContext applies when no named groups are
+ * configured, is not an option of the user: losing it is only logged at
DEBUG.
+ */
+ private void logDroppedSslOptions(SSLContextParameters
sslContextParameters) {
+ if (droppedSslOptionsLogged) {
+ return;
+ }
+ droppedSslOptionsLogged = true;
+
+ List<String> dropped =
JsseParametersHelper.engineOnlyParameters(sslContextParameters);
+ if (!dropped.isEmpty()) {
+ LOG.warn("The Kafka client cannot apply the {} of
sslContextParameters: it creates its TLS connections from"
+ + " the ssl.* properties, which have no such settings, so
the JVM defaults are used instead",
+ String.join(", ", dropped));
+ } else if (LOG.isDebugEnabled()) {
+ List<String> postQuantum =
JsseParametersHelper.postQuantumNamedGroups(sslContextParameters);
+ if (postQuantum != null) {
+ LOG.debug("The Kafka client cannot apply the post-quantum
named group order {} that sslContextParameters"
+ + " prefers on this JVM: it uses the named group
order of the JVM instead",
+ postQuantum);
+ }
+ }
+ }
+
/**
* Uses the standard camel {@link SSLContextParameters} object to fill the
Kafka SSL properties
*
diff --git
a/components/camel-kafka-common/src/test/java/org/apache/camel/component/kafka/KafkaClientConfigurationSslTest.java
b/components/camel-kafka-common/src/test/java/org/apache/camel/component/kafka/KafkaClientConfigurationSslTest.java
new file mode 100644
index 000000000000..8b1718226223
--- /dev/null
+++
b/components/camel-kafka-common/src/test/java/org/apache/camel/component/kafka/KafkaClientConfigurationSslTest.java
@@ -0,0 +1,138 @@
+/*
+ * 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.kafka;
+
+import java.util.List;
+import java.util.Properties;
+import java.util.concurrent.CopyOnWriteArrayList;
+import java.util.concurrent.TimeUnit;
+
+import org.apache.camel.support.jsse.CipherSuitesParameters;
+import org.apache.camel.support.jsse.NamedGroupsParameters;
+import org.apache.camel.support.jsse.SSLContextParameters;
+import org.apache.camel.support.jsse.SignatureSchemesParameters;
+import org.apache.kafka.common.config.SslConfigs;
+import org.apache.logging.log4j.Level;
+import org.apache.logging.log4j.LogManager;
+import org.apache.logging.log4j.core.LogEvent;
+import org.apache.logging.log4j.core.Logger;
+import org.apache.logging.log4j.core.appender.AbstractAppender;
+import org.apache.logging.log4j.core.config.Property;
+import org.junit.jupiter.api.AfterEach;
+import org.junit.jupiter.api.BeforeEach;
+import org.junit.jupiter.api.Test;
+
+import static org.awaitility.Awaitility.await;
+import static org.junit.jupiter.api.Assertions.assertEquals;
+import static org.junit.jupiter.api.Assertions.assertFalse;
+import static org.junit.jupiter.api.Assertions.assertTrue;
+
+/**
+ * The Kafka client builds its TLS connections from the ssl.* properties,
which cannot carry the named groups and the
+ * signature schemes of sslContextParameters. The configuration says so with a
WARN, once per endpoint, instead of
+ * dropping them in silence.
+ */
+class KafkaClientConfigurationSslTest {
+
+ private final List<String> warnings = new CopyOnWriteArrayList<>();
+ private final Logger logger = (Logger)
LogManager.getLogger(KafkaClientConfiguration.class);
+ private final String thread = Thread.currentThread().getName();
+ private final AbstractAppender appender
+ = new AbstractAppender("KafkaClientConfigurationSslTest", null,
null, true, Property.EMPTY_ARRAY) {
+ @Override
+ public void append(LogEvent event) {
+ // only the events of this test, as other tests may run at
the same time
+ if (event.getLevel().isMoreSpecificThan(Level.WARN) &&
thread.equals(event.getThreadName())) {
+ warnings.add(event.getMessage().getFormattedMessage());
+ }
+ }
+ };
+
+ @BeforeEach
+ void captureWarnings() {
+ // an appender added while another test still starts log4j would be
dropped with the old configuration
+ await().atMost(30,
TimeUnit.SECONDS).until(logger.getContext()::isStarted);
+ appender.start();
+ logger.addAppender(appender);
+ }
+
+ @AfterEach
+ void stopCapture() {
+ logger.removeAppender(appender);
+ appender.stop();
+ }
+
+ @Test
+ void namedGroupsAndSignatureSchemesAreReportedOncePerEndpoint() {
+ SSLContextParameters scp = new SSLContextParameters();
+ NamedGroupsParameters ngp = new NamedGroupsParameters();
+ ngp.setNamedGroup(List.of("secp384r1"));
+ scp.setNamedGroups(ngp);
+ SignatureSchemesParameters ssp = new SignatureSchemesParameters();
+ ssp.setSignatureScheme(List.of("ecdsa_secp384r1_sha384"));
+ scp.setSignatureSchemes(ssp);
+ scp.setSecureSocketProtocol("TLSv1.3");
+
+ TestConfiguration configuration = new TestConfiguration();
+ configuration.setSslContextParameters(scp);
+
+ // the properties of a client are created at each start of a client,
and once for each consumer
+ Properties props = configuration.createProperties();
+ configuration.createProperties();
+ configuration.createProperties();
+
+ // the settings that the ssl.* properties can carry are still mapped
+ assertEquals("TLSv1.3", props.get(SslConfigs.SSL_PROTOCOL_CONFIG));
+ assertEquals(1, warnings.size(), "a single warning: " + warnings);
+ assertTrue(warnings.get(0).contains("namedGroups, signatureSchemes"),
warnings.get(0));
+
+ // an endpoint gets a copy of the configuration of the component,
which warns on its own
+ configuration.copy().createProperties();
+ assertEquals(2, warnings.size(), "a warning for the copy: " +
warnings);
+ }
+
+ @Test
+ void noWarningWithoutNamedGroupsOrSignatureSchemes() {
+ SSLContextParameters scp = new SSLContextParameters();
+ CipherSuitesParameters csp = new CipherSuitesParameters();
+ csp.setCipherSuite(List.of("TLS_AES_256_GCM_SHA384"));
+ scp.setCipherSuites(csp);
+
+ TestConfiguration configuration = new TestConfiguration();
+ configuration.setSslContextParameters(scp);
+
+ Properties props = configuration.createProperties();
+
+ assertEquals("TLS_AES_256_GCM_SHA384",
props.get(SslConfigs.SSL_CIPHER_SUITES_CONFIG));
+ assertFalse(props.isEmpty());
+ assertTrue(warnings.isEmpty(), "no warning: " + warnings);
+ }
+
+ private static final class TestConfiguration extends
KafkaClientConfiguration {
+
+ Properties createProperties() {
+ Properties props = new Properties();
+ applySecurityProperties(props);
+ return props;
+ }
+
+ @Override
+ protected TestConfiguration copy() {
+ return (TestConfiguration) super.copy();
+ }
+ }
+}
diff --git a/components/camel-kafka-common/src/test/resources/log4j2.properties
b/components/camel-kafka-common/src/test/resources/log4j2.properties
new file mode 100644
index 000000000000..b6e4ccdfc791
--- /dev/null
+++ b/components/camel-kafka-common/src/test/resources/log4j2.properties
@@ -0,0 +1,25 @@
+## ---------------------------------------------------------------------------
+## 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.
+## ---------------------------------------------------------------------------
+
+appender.out.type = File
+appender.out.name = out
+appender.out.fileName = target/camel-kafka-common-test.log
+appender.out.layout.type = PatternLayout
+appender.out.layout.pattern = %d [%-15.15t] %-5p %-30.30c{1} - %m%n
+
+rootLogger.level = INFO
+rootLogger.appenderRef.out.ref = out
diff --git a/components/camel-kafka/src/main/docs/kafka-component.adoc
b/components/camel-kafka/src/main/docs/kafka-component.adoc
index 247e1c977402..c0faf32bc841 100644
--- a/components/camel-kafka/src/main/docs/kafka-component.adoc
+++ b/components/camel-kafka/src/main/docs/kafka-component.adoc
@@ -2176,3 +2176,10 @@ YAML::
uri: mock:result
----
====
+
+The Kafka client creates its TLS connections from its `ssl.*` properties,
which the `sslContextParameters` are mapped
+to: the protocol, the provider, the cipher suites, the enabled protocols and
the key and trust stores. The Kafka client
+has no properties for the named groups and the signature schemes, so these are
not applied: a `WARN` is logged when
+they are configured, and the client uses the named groups of the JVM, also for
the post-quantum preference that
+`SSLContextParameters` applies elsewhere. See _Components with their own TLS
stack_ in the xref:manual::camel-configuration-utilities.adoc[Camel JSSE
Configuration Utility] for
+setting them for the whole JVM instead.
diff --git
a/components/camel-netty/src/main/java/org/apache/camel/component/netty/ssl/SSLEngineFactory.java
b/components/camel-netty/src/main/java/org/apache/camel/component/netty/ssl/SSLEngineFactory.java
index 964e38cd1f1c..0b7429e9376c 100644
---
a/components/camel-netty/src/main/java/org/apache/camel/component/netty/ssl/SSLEngineFactory.java
+++
b/components/camel-netty/src/main/java/org/apache/camel/component/netty/ssl/SSLEngineFactory.java
@@ -17,10 +17,7 @@
package org.apache.camel.component.netty.ssl;
import java.io.InputStream;
-import java.lang.reflect.Method;
import java.security.KeyStore;
-import java.util.ArrayList;
-import java.util.Arrays;
import java.util.List;
import javax.net.ssl.KeyManagerFactory;
@@ -31,6 +28,7 @@ import javax.net.ssl.TrustManagerFactory;
import org.apache.camel.CamelContext;
import org.apache.camel.support.ResourceHelper;
+import org.apache.camel.support.jsse.JsseParametersHelper;
import org.apache.camel.util.IOHelper;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
@@ -41,28 +39,6 @@ public final class SSLEngineFactory {
private static final String SSL_PROTOCOL = "TLSv1.3";
- // PQC named group constants — keep in sync with
SSLContextParameters.PQC_NAMED_GROUP
- // and SSLContextParameters.PQC_PREFERRED_NAMED_GROUPS
- private static final String PQC_NAMED_GROUP = "X25519MLKEM768";
- private static final List<String> PQC_PREFERRED_NAMED_GROUPS
- = List.of("X25519MLKEM768", "x25519", "secp256r1", "secp384r1");
-
- // Reflection handles for JDK 20+ SSLParameters named groups API
- private static final Method GET_NAMED_GROUPS;
- private static final Method SET_NAMED_GROUPS;
-
- static {
- Method gng = null, sng = null;
- try {
- gng = SSLParameters.class.getMethod("getNamedGroups");
- sng = SSLParameters.class.getMethod("setNamedGroups",
String[].class);
- } catch (NoSuchMethodException e) {
- // JDK < 20 — named groups API not available
- }
- GET_NAMED_GROUPS = gng;
- SET_NAMED_GROUPS = sng;
- }
-
public SSLEngineFactory() {
}
@@ -104,45 +80,23 @@ public final class SSLEngineFactory {
}
/**
- * Applies post-quantum named group defaults to an {@link SSLEngine} when
the JVM supports them (typically JDK 25+).
+ * Applies post-quantum named group defaults to an {@link SSLEngine} when
the JVM supports them.
* <p>
- * When {@code X25519MLKEM768} is available, this method reorders the
named groups to prioritize post-quantum key
- * exchange, matching the auto-configuration behavior of
- * {@link
org.apache.camel.support.jsse.SSLContextParameters#createSSLContext}. This
should be called on SSLEngines
+ * When the JVM offers a post-quantum hybrid group but does not lead with
one, this method reorders the named groups
+ * to prefer post-quantum key exchange, with the same order as the
auto-configuration of
+ * {@link
org.apache.camel.support.jsse.SSLContextParameters#createSSLContext}, which
+ * {@link JsseParametersHelper#postQuantumNamedGroups(String[])} computes.
This should be called on SSLEngines
* created via the SSLEngineFactory fallback path (without
SSLContextParameters).
*/
public static void applyPqcNamedGroups(SSLEngine engine) {
- if (GET_NAMED_GROUPS == null || SET_NAMED_GROUPS == null) {
- return;
- }
-
try {
SSLParameters params = engine.getSSLParameters();
- String[] availableGroups = (String[])
GET_NAMED_GROUPS.invoke(params);
-
- if (availableGroups == null) {
- return;
- }
-
- List<String> available = Arrays.asList(availableGroups);
- if (!available.contains(PQC_NAMED_GROUP)) {
+ List<String> ordered =
JsseParametersHelper.postQuantumNamedGroups(params.getNamedGroups());
+ if (ordered == null) {
return;
}
- // Build preferred ordering: PQC preferred groups first, then
remaining
- List<String> ordered = new ArrayList<>();
- for (String preferred : PQC_PREFERRED_NAMED_GROUPS) {
- if (available.contains(preferred)) {
- ordered.add(preferred);
- }
- }
- for (String group : availableGroups) {
- if (!ordered.contains(group)) {
- ordered.add(group);
- }
- }
-
- SET_NAMED_GROUPS.invoke(params, (Object) ordered.toArray(new
String[0]));
+ params.setNamedGroups(ordered.toArray(new String[0]));
engine.setSSLParameters(params);
LOG.debug("Applied PQC named groups to SSLEngine: {}", ordered);
diff --git
a/components/camel-netty/src/test/java/org/apache/camel/component/netty/SSLEngineFactoryTest.java
b/components/camel-netty/src/test/java/org/apache/camel/component/netty/SSLEngineFactoryTest.java
index e1424e8a659f..65f545b9317f 100644
---
a/components/camel-netty/src/test/java/org/apache/camel/component/netty/SSLEngineFactoryTest.java
+++
b/components/camel-netty/src/test/java/org/apache/camel/component/netty/SSLEngineFactoryTest.java
@@ -30,6 +30,7 @@ import org.junit.jupiter.api.Test;
import static org.junit.jupiter.api.Assertions.assertEquals;
import static org.junit.jupiter.api.Assertions.assertNotNull;
import static org.junit.jupiter.api.Assertions.assertTrue;
+import static org.junit.jupiter.api.Assumptions.assumeTrue;
class SSLEngineFactoryTest {
@@ -97,6 +98,39 @@ class SSLEngineFactoryTest {
assertEquals("TLSv1.3", protocols[0]);
}
+ @Test
+ void testApplyPqcNamedGroupsReordersAnOrderThatDoesNotLeadWithAHybrid()
throws Exception {
+ SSLEngine engine = engineWithNamedGroups("x25519", "secp256r1",
"X25519MLKEM768", "secp384r1", "ffdhe2048");
+
+ SSLEngineFactory.applyPqcNamedGroups(engine);
+
+ assertEquals(List.of("X25519MLKEM768", "x25519", "secp256r1",
"secp384r1", "ffdhe2048"),
+ List.of(engine.getSSLParameters().getNamedGroups()));
+ }
+
+ @Test
+ void testApplyPqcNamedGroupsLeavesAnOrderThatLeadsWithAHybridAlone()
throws Exception {
+ // such as a CNSA 2.0 order chosen with jdk.tls.namedGroups, the same
as SSLContextParameters keeps
+ SSLEngine engine = engineWithNamedGroups("SecP384r1MLKEM1024",
"x25519", "X25519MLKEM768", "secp384r1");
+
+ SSLEngineFactory.applyPqcNamedGroups(engine);
+
+ assertEquals(List.of("SecP384r1MLKEM1024", "x25519", "X25519MLKEM768",
"secp384r1"),
+ List.of(engine.getSSLParameters().getNamedGroups()));
+ }
+
+ private static SSLEngine engineWithNamedGroups(String... groups) throws
Exception {
+ SSLContext context = SSLContext.getInstance("TLSv1.3");
+ context.init(null, null, null);
+ SSLEngine engine = context.createSSLEngine();
+ SSLParameters params = engine.getSSLParameters();
+ params.setNamedGroups(groups);
+ engine.setSSLParameters(params);
+ // the JVM keeps the named groups as they are set, also the ones it
does not know
+
assumeTrue(List.of(groups).equals(List.of(engine.getSSLParameters().getNamedGroups())));
+ return engine;
+ }
+
@Test
public void testSslProtocolIsTls13() throws Exception {
SSLContext context = SSLContext.getInstance("TLSv1.3");
diff --git a/components/camel-thrift/src/main/docs/thrift-component.adoc
b/components/camel-thrift/src/main/docs/thrift-component.adoc
index 9337cd0cf62f..df4dbc8bff33 100644
--- a/components/camel-thrift/src/main/docs/thrift-component.adoc
+++ b/components/camel-thrift/src/main/docs/thrift-component.adoc
@@ -194,6 +194,12 @@
from("thrift://0.0.0.0:1101/org.apache.camel.component.thrift.generated.Calculat
.to("direct:thrift-service");
----
+The producer creates its TLS connection with the Thrift
`TSSLTransportFactory`, from the secure socket protocol, the
+cipher suites and the trust store of `sslParameters` only. The named groups
and the signature schemes are not applied
+by the producer, and a `WARN` is logged when they are configured. The producer
uses the named groups of the JVM, also
+for the post-quantum preference that `SSLContextParameters` applies elsewhere.
See _Components with their own TLS
+stack_ in the xref:manual::camel-configuration-utilities.adoc[Camel JSSE
Configuration Utility].
+
== Errors sent to the client
When the exchange of a consumer fails, the Thrift client receives an error. An
exception that the Thrift method
diff --git
a/components/camel-thrift/src/main/java/org/apache/camel/component/thrift/ThriftProducer.java
b/components/camel-thrift/src/main/java/org/apache/camel/component/thrift/ThriftProducer.java
index 73cb2b3bed73..e98636378bf7 100644
---
a/components/camel-thrift/src/main/java/org/apache/camel/component/thrift/ThriftProducer.java
+++
b/components/camel-thrift/src/main/java/org/apache/camel/component/thrift/ThriftProducer.java
@@ -17,6 +17,7 @@
package org.apache.camel.component.thrift;
import java.io.IOException;
+import java.util.List;
import java.util.Set;
import java.util.concurrent.ConcurrentHashMap;
import java.util.concurrent.atomic.AtomicBoolean;
@@ -29,6 +30,7 @@ import org.apache.camel.Message;
import org.apache.camel.component.thrift.client.AsyncClientMethodCallback;
import org.apache.camel.support.DefaultAsyncProducer;
import org.apache.camel.support.ResourceHelper;
+import org.apache.camel.support.jsse.JsseParametersHelper;
import org.apache.camel.support.jsse.SSLContextParameters;
import org.apache.camel.util.ObjectHelper;
import org.apache.thrift.TException;
@@ -292,6 +294,8 @@ public class ThriftProducer extends DefaultAsyncProducer
implements AsyncProduce
LOG.info("Creating secured transport to the remote Thrift server
{}:{}", configuration.getHost(),
configuration.getPort());
+ logDroppedSslOptions(sslParameters);
+
TSSLTransportFactory.TSSLTransportParameters sslParams;
sslParams = new TSSLTransportFactory.TSSLTransportParameters(
@@ -319,4 +323,26 @@ public class ThriftProducer extends DefaultAsyncProducer
implements AsyncProduce
throw new IllegalArgumentException("No connection properties
(host, port) specified");
}
}
+
+ /**
+ * The Thrift client builds its TLS connection from
TSSLTransportParameters, which cannot carry the options that
+ * only the SSLContext of {@code SSLContextParameters.createSSLContext}
applies: say so instead of dropping them in
+ * silence. The post-quantum preference of the named groups, which that
SSLContext applies when no named groups are
+ * configured, is not an option of the user: losing it is only logged at
DEBUG.
+ */
+ private static void logDroppedSslOptions(SSLContextParameters
sslParameters) {
+ List<String> dropped =
JsseParametersHelper.engineOnlyParameters(sslParameters);
+ if (!dropped.isEmpty()) {
+ LOG.warn("The Thrift producer cannot apply the {} of
sslParameters: it creates its TLS connection from the"
+ + " protocol, cipher suites and trust store only, so the
JVM defaults are used instead",
+ String.join(", ", dropped));
+ } else if (LOG.isDebugEnabled()) {
+ List<String> postQuantum =
JsseParametersHelper.postQuantumNamedGroups(sslParameters);
+ if (postQuantum != null) {
+ LOG.debug("The Thrift producer cannot apply the post-quantum
named group order {} that sslParameters"
+ + " prefers on this JVM: it uses the named group
order of the JVM instead",
+ postQuantum);
+ }
+ }
+ }
}
diff --git
a/components/camel-thrift/src/test/java/org/apache/camel/component/thrift/ThriftProducerSslOptionsTest.java
b/components/camel-thrift/src/test/java/org/apache/camel/component/thrift/ThriftProducerSslOptionsTest.java
new file mode 100644
index 000000000000..ad3b5d9aff6c
--- /dev/null
+++
b/components/camel-thrift/src/test/java/org/apache/camel/component/thrift/ThriftProducerSslOptionsTest.java
@@ -0,0 +1,155 @@
+/*
+ * 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.thrift;
+
+import java.net.InetAddress;
+import java.util.List;
+import java.util.concurrent.CopyOnWriteArrayList;
+import java.util.concurrent.TimeUnit;
+
+import org.apache.camel.builder.RouteBuilder;
+import org.apache.camel.component.thrift.generated.Calculator;
+import org.apache.camel.component.thrift.impl.CalculatorSyncServerImpl;
+import org.apache.camel.spi.Registry;
+import org.apache.camel.support.jsse.KeyStoreParameters;
+import org.apache.camel.support.jsse.NamedGroupsParameters;
+import org.apache.camel.support.jsse.SSLContextParameters;
+import org.apache.camel.support.jsse.TrustManagersParameters;
+import org.apache.camel.test.junit6.CamelTestSupport;
+import org.apache.logging.log4j.Level;
+import org.apache.logging.log4j.LogManager;
+import org.apache.logging.log4j.core.LogEvent;
+import org.apache.logging.log4j.core.Logger;
+import org.apache.logging.log4j.core.appender.AbstractAppender;
+import org.apache.logging.log4j.core.config.Property;
+import org.apache.thrift.server.TServer;
+import org.apache.thrift.server.TThreadPoolServer;
+import org.apache.thrift.transport.TSSLTransportFactory;
+import org.apache.thrift.transport.TServerSocket;
+import org.junit.jupiter.api.AfterEach;
+import org.junit.jupiter.api.Test;
+
+import static org.awaitility.Awaitility.await;
+import static org.junit.jupiter.api.Assertions.assertEquals;
+import static org.junit.jupiter.api.Assertions.assertTrue;
+
+/**
+ * The SSL producer builds its TLS connection from TSSLTransportParameters,
which cannot carry the named groups of
+ * sslParameters. It says so with a WARN when it starts, instead of dropping
them in silence.
+ */
+public class ThriftProducerSslOptionsTest extends CamelTestSupport {
+
+ private static final String TRUST_STORE_SOURCE =
"file:src/test/resources/certs/truststore.jks";
+ private static final String KEY_STORE_SOURCE =
"file:src/test/resources/certs/keystore.jks";
+ private static final String SECURITY_STORE_PASSWORD = "camelinaction";
+ private static final int THRIFT_CLIENT_TIMEOUT = 2000;
+
+ private final List<String> warnings = new CopyOnWriteArrayList<>();
+ private final Logger logger = (Logger)
LogManager.getLogger(ThriftProducer.class);
+ private final String thread = Thread.currentThread().getName();
+ private final AbstractAppender appender
+ = new AbstractAppender("ThriftProducerSslOptionsTest", null, null,
true, Property.EMPTY_ARRAY) {
+ @Override
+ public void append(LogEvent event) {
+ // only the events of this test, as other tests may run at
the same time
+ if (event.getLevel().isMoreSpecificThan(Level.WARN) &&
thread.equals(event.getThreadName())) {
+ warnings.add(event.getMessage().getFormattedMessage());
+ }
+ }
+ };
+
+ private TServerSocket serverTransport;
+ private TServer server;
+ private int thriftTestPort;
+
+ @Override
+ @SuppressWarnings({ "unchecked", "rawtypes" })
+ public void doPreSetup() throws Exception {
+ // the producer starts with the CamelContext, so capture its log before
+ // an appender added while another test still starts log4j would be
dropped with the old configuration
+ await().atMost(30,
TimeUnit.SECONDS).until(logger.getContext()::isStarted);
+ appender.start();
+ logger.addAppender(appender);
+
+ TSSLTransportFactory.TSSLTransportParameters sslParams = new
TSSLTransportFactory.TSSLTransportParameters();
+ sslParams.setKeyStore(KEY_STORE_SOURCE, SECURITY_STORE_PASSWORD);
+ serverTransport = TSSLTransportFactory.getServerSocket(0,
THRIFT_CLIENT_TIMEOUT,
+ InetAddress.getByName("localhost"), sslParams);
+ thriftTestPort = serverTransport.getServerSocket().getLocalPort();
+ TThreadPoolServer.Args args = new
TThreadPoolServer.Args(serverTransport);
+ args.processor(new Calculator.Processor(new
CalculatorSyncServerImpl()));
+ server = new TThreadPoolServer(args);
+ new Thread(server::serve,
"ThriftProducerSslOptionsTest-server").start();
+ }
+
+ @Override
+ protected void cleanupResources() throws Exception {
+ if (server != null) {
+ server.stop();
+ serverTransport.close();
+ }
+ }
+
+ @AfterEach
+ void stopCapture() {
+ logger.removeAppender(appender);
+ appender.stop();
+ }
+
+ @Override
+ protected void bindToRegistry(Registry registry) {
+ KeyStoreParameters keyStoreParams = new KeyStoreParameters();
+ keyStoreParams.setResource(TRUST_STORE_SOURCE);
+ keyStoreParams.setPassword(SECURITY_STORE_PASSWORD);
+ TrustManagersParameters trustManagerParams = new
TrustManagersParameters();
+ trustManagerParams.setKeyStore(keyStoreParams);
+
+ NamedGroupsParameters namedGroups = new NamedGroupsParameters();
+ namedGroups.setNamedGroup(List.of("x25519", "secp256r1"));
+
+ SSLContextParameters sslParameters = new SSLContextParameters();
+ sslParameters.setTrustManagers(trustManagerParams);
+ sslParameters.setNamedGroups(namedGroups);
+
+ registry.bind("sslParams", sslParameters);
+ }
+
+ @Test
+ public void testNamedGroupsAreReportedOnceAtStart() {
+ Object first = template.requestBody("direct:thrift-secured-add",
List.of(1, 2));
+ Object second = template.requestBody("direct:thrift-secured-add",
List.of(3, 4));
+
+ // the producer still connects, with the trust store of sslParameters
+ assertEquals(3, first);
+ assertEquals(7, second);
+ assertEquals(1, warnings.size(), "a single warning: " + warnings);
+ assertTrue(warnings.get(0).contains("namedGroups"), warnings.get(0));
+ }
+
+ @Override
+ protected RouteBuilder createRouteBuilder() {
+ return new RouteBuilder() {
+ @Override
+ public void configure() {
+ from("direct:thrift-secured-add")
+ .to("thrift://localhost:" + thriftTestPort
+ +
"/org.apache.camel.component.thrift.generated.Calculator?"
+ +
"method=add&negotiationType=SSL&sslParameters=#sslParams&synchronous=true");
+ }
+ };
+ }
+}
diff --git
a/components/camel-vertx/camel-vertx-common/src/main/java/org/apache/camel/component/vertx/common/VertxHelper.java
b/components/camel-vertx/camel-vertx-common/src/main/java/org/apache/camel/component/vertx/common/VertxHelper.java
index ac32dd9336d1..7df2b2d02408 100644
---
a/components/camel-vertx/camel-vertx-common/src/main/java/org/apache/camel/component/vertx/common/VertxHelper.java
+++
b/components/camel-vertx/camel-vertx-common/src/main/java/org/apache/camel/component/vertx/common/VertxHelper.java
@@ -17,6 +17,7 @@
package org.apache.camel.component.vertx.common;
import java.security.KeyStore;
+import java.util.ArrayList;
import java.util.LinkedHashSet;
import java.util.List;
import java.util.Locale;
@@ -29,25 +30,36 @@ import javax.net.ssl.TrustManagerFactory;
import javax.net.ssl.X509KeyManager;
import io.vertx.core.http.ClientAuth;
+import io.vertx.core.net.JdkSSLEngineOptions;
import io.vertx.core.net.KeyCertOptions;
import io.vertx.core.net.NetServerOptions;
+import io.vertx.core.net.SSLEngineOptions;
+import io.vertx.core.net.SSLOptions;
import io.vertx.core.net.TCPSSLOptions;
import io.vertx.core.net.TrustOptions;
import org.apache.camel.CamelContext;
import org.apache.camel.support.jsse.ClientAuthentication;
+import org.apache.camel.support.jsse.JsseParametersHelper;
import org.apache.camel.support.jsse.KeyManagersParameters;
import org.apache.camel.support.jsse.SSLContextParameters;
import org.apache.camel.support.jsse.TrustManagersParameters;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
public final class VertxHelper {
+ private static final Logger LOG =
LoggerFactory.getLogger(VertxHelper.class);
+
private VertxHelper() {
// Utility class
}
/**
- * Configures key store and trust store options, the client authentication
(of a server) and the cipher suites and
- * protocols for the given TCPSSLOptions from the configuration specified
on SSLContextParameters
+ * Configures key store and trust store options, the client authentication
(of a server), the cipher suites, the
+ * protocols and the named groups (key exchange groups) for the given
TCPSSLOptions from the configuration specified
+ * on SSLContextParameters. The named groups include the post-quantum
preference that
+ * {@link SSLContextParameters#createSSLContext(CamelContext)} applies
when none are configured. The signature
+ * schemes cannot be applied, as Vert.x has no such setting, and a WARN
says so when they are configured.
*
* @param camelContext the CamelContext
* @param sslContextParameters the SSL configuration to use for the
KeyManagerFactory & TrustManagerFactory
@@ -111,13 +123,19 @@ public final class VertxHelper {
});
}
- // the cipher suites and protocols (when configured) as computed by
the SSLContextParameters
+ // the cipher suites, protocols and named groups (when configured) as
computed by the SSLContextParameters
// (such as from the include and exclude filters)
boolean cipherSuites = sslContextParameters.getCipherSuites() != null
|| sslContextParameters.getCipherSuitesFilter() != null;
boolean protocols = sslContextParameters.getSecureSocketProtocols() !=
null
|| sslContextParameters.getSecureSocketProtocolsFilter() !=
null;
- if (cipherSuites || protocols) {
+ boolean namedGroups = sslContextParameters.getNamedGroups() != null
+ || sslContextParameters.getNamedGroupsFilter() != null;
+ // the post-quantum preference that the SSLContext applies when no
named groups are configured, which a Vert.x
+ // engine of the JDK can take as well
+ boolean postQuantum = !namedGroups &&
isJdkEngine(tcpsslOptions.getSslEngineOptions())
+ &&
JsseParametersHelper.postQuantumNamedGroups(sslContextParameters) != null;
+ if (cipherSuites || protocols || namedGroups || postQuantum) {
SSLEngine engine =
sslContextParameters.createSSLContext(camelContext).createSSLEngine();
if (cipherSuites) {
for (String suite : engine.getEnabledCipherSuites()) {
@@ -127,9 +145,41 @@ public final class VertxHelper {
if (protocols) {
tcpsslOptions.setEnabledSecureTransportProtocols(new
LinkedHashSet<>(List.of(engine.getEnabledProtocols())));
}
+ String[] groups = engine.getSSLParameters().getNamedGroups();
+ if ((namedGroups || postQuantum) && groups != null) {
+ // Vert.x applies its key exchange groups on each SSLEngine it
creates, server and client side
+ sslOptions(tcpsslOptions).setKeyExchangeGroups(new
ArrayList<>(List.of(groups)));
+ }
+ }
+
+ // Vert.x has no setting for the signature schemes
+ if (sslContextParameters.getSignatureSchemes() != null ||
sslContextParameters.getSignatureSchemesFilter() != null) {
+ LOG.warn("Vert.x cannot apply the signature schemes of
sslContextParameters, as its TLS options have no such"
+ + " setting: the signature schemes of the JVM are used
instead");
}
}
+ /**
+ * The SSL options of the given TCP SSL options, which Vert.x creates on
the first SSL setting.
+ */
+ private static SSLOptions sslOptions(TCPSSLOptions tcpsslOptions) {
+ SSLOptions answer = tcpsslOptions.getSslOptions();
+ if (answer == null) {
+ // TCPSSLOptions.getOrCreateSSLOptions() is protected, but each
SSL setter calls it, so set the value the
+ // options already have (VertxHelperNamedGroupsTest fails if a
Vert.x upgrade changes this)
+
tcpsslOptions.setSslHandshakeTimeout(tcpsslOptions.getSslHandshakeTimeout());
+ answer = tcpsslOptions.getSslOptions();
+ }
+ return answer;
+ }
+
+ /**
+ * Whether Vert.x uses the SSLEngine of the JDK, which knows the named
groups of the JVM, rather than OpenSSL.
+ */
+ private static boolean isJdkEngine(SSLEngineOptions engineOptions) {
+ return engineOptions == null || engineOptions instanceof
JdkSSLEngineOptions;
+ }
+
private static KeyManagerFactory createKeyManagerFactory(
CamelContext camelContext, SSLContextParameters
sslContextParameters)
throws Exception {
diff --git
a/components/camel-vertx/camel-vertx-common/src/test/java/org/apache/camel/component/vertx/common/VertxHelperNamedGroupsTest.java
b/components/camel-vertx/camel-vertx-common/src/test/java/org/apache/camel/component/vertx/common/VertxHelperNamedGroupsTest.java
new file mode 100644
index 000000000000..1feab8f1de36
--- /dev/null
+++
b/components/camel-vertx/camel-vertx-common/src/test/java/org/apache/camel/component/vertx/common/VertxHelperNamedGroupsTest.java
@@ -0,0 +1,256 @@
+/*
+ * 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.vertx.common;
+
+import java.io.InputStream;
+import java.net.InetAddress;
+import java.security.KeyStore;
+import java.util.List;
+import java.util.concurrent.CopyOnWriteArrayList;
+import java.util.concurrent.ExecutionException;
+import java.util.concurrent.TimeUnit;
+
+import javax.net.ssl.KeyManagerFactory;
+import javax.net.ssl.SSLContext;
+import javax.net.ssl.SSLException;
+import javax.net.ssl.SSLParameters;
+import javax.net.ssl.SSLServerSocket;
+import javax.net.ssl.SSLSocket;
+import javax.net.ssl.TrustManager;
+
+import io.vertx.core.Future;
+import io.vertx.core.Vertx;
+import io.vertx.core.net.NetClient;
+import io.vertx.core.net.NetClientOptions;
+import io.vertx.core.net.NetServer;
+import io.vertx.core.net.NetServerOptions;
+import io.vertx.core.net.NetSocket;
+import org.apache.camel.CamelContext;
+import org.apache.camel.impl.DefaultCamelContext;
+import org.apache.camel.support.jsse.JsseParametersHelper;
+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.SSLContextParameters;
+import org.apache.camel.support.jsse.SignatureSchemesParameters;
+import org.apache.camel.support.jsse.TrustAllTrustManager;
+import org.apache.camel.support.jsse.TrustManagersParameters;
+import org.apache.logging.log4j.Level;
+import org.apache.logging.log4j.LogManager;
+import org.apache.logging.log4j.core.LogEvent;
+import org.apache.logging.log4j.core.Logger;
+import org.apache.logging.log4j.core.appender.AbstractAppender;
+import org.apache.logging.log4j.core.config.Property;
+import org.junit.jupiter.api.AfterEach;
+import org.junit.jupiter.api.BeforeEach;
+import org.junit.jupiter.api.Test;
+
+import static org.assertj.core.api.Assertions.assertThat;
+import static org.assertj.core.api.Assertions.assertThatThrownBy;
+import static org.awaitility.Awaitility.await;
+
+/**
+ * The named groups of sslContextParameters reach the TLS handshakes of
Vert.x, on the server and on the client side, as
+ * its key exchange groups. The signature schemes, which Vert.x has no setting
for, are reported with a WARN.
+ */
+public class VertxHelperNamedGroupsTest {
+
+ private static final String PASSWORD = "security";
+
+ private final List<String> warnings = new CopyOnWriteArrayList<>();
+ private final Logger logger = (Logger)
LogManager.getLogger(VertxHelper.class);
+ private final String thread = Thread.currentThread().getName();
+ private final AbstractAppender appender
+ = new AbstractAppender("VertxHelperNamedGroupsTest", null, null,
true, Property.EMPTY_ARRAY) {
+ @Override
+ public void append(LogEvent event) {
+ // only the events of this test, as other tests may run at
the same time
+ if (event.getLevel().isMoreSpecificThan(Level.WARN) &&
thread.equals(event.getThreadName())) {
+ warnings.add(event.getMessage().getFormattedMessage());
+ }
+ }
+ };
+
+ private CamelContext context;
+ private Vertx vertx;
+
+ @BeforeEach
+ public void setUp() {
+ context = new DefaultCamelContext();
+ vertx = Vertx.vertx();
+ // an appender added while another test still starts log4j would be
dropped with the old configuration
+ await().atMost(30,
TimeUnit.SECONDS).until(logger.getContext()::isStarted);
+ appender.start();
+ logger.addAppender(appender);
+ }
+
+ @AfterEach
+ public void tearDown() throws Exception {
+ logger.removeAppender(appender);
+ appender.stop();
+ if (vertx != null) {
+ vertx.close().toCompletionStage().toCompletableFuture().get(30,
TimeUnit.SECONDS);
+ }
+ if (context != null) {
+ context.stop();
+ }
+ }
+
+ @Test
+ public void testServerOffersOnlyTheConfiguredNamedGroups() throws
Exception {
+ SSLContextParameters scp = serverParameters();
+ scp.setNamedGroups(namedGroups("secp256r1"));
+
+ NetServerOptions options = new
NetServerOptions().setHost("localhost").setPort(0);
+ VertxHelper.setupSSLOptions(context, scp, options);
+
+ NetServer server =
result(vertx.createNetServer(options).connectHandler(NetSocket::close).listen());
+ int port = server.actualPort();
+
+ // a client that offers another group only finds no group in common
+ assertThatThrownBy(() -> handshake(port,
"x25519")).isInstanceOf(SSLException.class);
+ // and one that offers the configured group connects
+ handshake(port, "secp256r1");
+
+
assertThat(options.getSslOptions().getKeyExchangeGroups()).containsExactly("secp256r1");
+ }
+
+ @Test
+ public void testClientOffersOnlyTheConfiguredNamedGroups() throws
Exception {
+ SSLContextParameters scp = new SSLContextParameters();
+ TrustManagersParameters tmp = new TrustManagersParameters();
+ tmp.setTrustManager(TrustAllTrustManager.INSTANCE);
+ scp.setTrustManagers(tmp);
+ scp.setNamedGroups(namedGroups("x25519"));
+
+ // the client connects to the loopback address, which the certificate
does not name
+ NetClientOptions options = new
NetClientOptions().setHostnameVerificationAlgorithm("");
+ VertxHelper.setupSSLOptions(context, scp, options);
+ NetClient client = vertx.createNetClient(options);
+
+ // a server that accepts another group only finds no group in common
+ try (SSLServerSocket serverSocket = serverSocket("secp256r1")) {
+ assertThatThrownBy(() -> connect(client,
serverSocket)).isInstanceOf(ExecutionException.class);
+ }
+ // and one that accepts the configured group is connected to
+ try (SSLServerSocket serverSocket = serverSocket("x25519")) {
+ connect(client, serverSocket);
+ }
+ }
+
+ @Test
+ public void testNoKeyExchangeGroupsWithoutNamedGroups() throws Exception {
+ SSLContextParameters scp = serverParameters();
+
+ NetServerOptions options = new NetServerOptions();
+ VertxHelper.setupSSLOptions(context, scp, options);
+
+ // Vert.x keeps the named groups of the JVM, unless Camel would
reorder them to prefer the post-quantum ones
+ SSLContext plain = SSLContext.getInstance("TLS");
+ plain.init(null, null, null);
+ List<String> postQuantum = JsseParametersHelper.postQuantumNamedGroups(
+ plain.getDefaultSSLParameters().getNamedGroups());
+ if (postQuantum == null) {
+
assertThat(options.getSslOptions().getKeyExchangeGroups()).isNull();
+ } else {
+
assertThat(options.getSslOptions().getKeyExchangeGroups()).containsExactlyElementsOf(postQuantum);
+ }
+ assertThat(warnings).isEmpty();
+ }
+
+ @Test
+ public void testSignatureSchemesAreReported() throws Exception {
+ SSLContextParameters scp = serverParameters();
+ SignatureSchemesParameters ssp = new SignatureSchemesParameters();
+ ssp.setSignatureScheme(List.of("ecdsa_secp256r1_sha256"));
+ scp.setSignatureSchemes(ssp);
+
+ VertxHelper.setupSSLOptions(context, scp, new NetServerOptions());
+
+ assertThat(warnings).singleElement().asString().contains("signature
schemes");
+ }
+
+ private static SSLContextParameters serverParameters() {
+ KeyStoreParameters ksp = new KeyStoreParameters();
+ ksp.setResource("jsse/service.jks");
+ ksp.setPassword(PASSWORD);
+ KeyManagersParameters kmp = new KeyManagersParameters();
+ kmp.setKeyStore(ksp);
+ kmp.setKeyPassword(PASSWORD);
+ SSLContextParameters scp = new SSLContextParameters();
+ scp.setKeyManagers(kmp);
+ return scp;
+ }
+
+ private static NamedGroupsParameters namedGroups(String... groups) {
+ NamedGroupsParameters ngp = new NamedGroupsParameters();
+ ngp.setNamedGroup(List.of(groups));
+ return ngp;
+ }
+
+ private static void handshake(int port, String namedGroup) throws
Exception {
+ SSLContext sslContext = SSLContext.getInstance("TLS");
+ sslContext.init(null, new TrustManager[] {
TrustAllTrustManager.INSTANCE }, null);
+ try (SSLSocket socket = (SSLSocket)
sslContext.getSocketFactory().createSocket("localhost", port)) {
+ socket.setSoTimeout(10000);
+ SSLParameters params = socket.getSSLParameters();
+ params.setNamedGroups(new String[] { namedGroup });
+ socket.setSSLParameters(params);
+ socket.startHandshake();
+ }
+ }
+
+ private static SSLServerSocket serverSocket(String namedGroup) throws
Exception {
+ KeyStore ks = KeyStore.getInstance("JKS");
+ try (InputStream is =
VertxHelperNamedGroupsTest.class.getClassLoader().getResourceAsStream("jsse/service.jks"))
{
+ ks.load(is, PASSWORD.toCharArray());
+ }
+ KeyManagerFactory kmf =
KeyManagerFactory.getInstance(KeyManagerFactory.getDefaultAlgorithm());
+ kmf.init(ks, PASSWORD.toCharArray());
+ SSLContext sslContext = SSLContext.getInstance("TLS");
+ sslContext.init(kmf.getKeyManagers(), null, null);
+ SSLServerSocket serverSocket = (SSLServerSocket)
sslContext.getServerSocketFactory()
+ .createServerSocket(0, 1, InetAddress.getLoopbackAddress());
+ SSLParameters params = serverSocket.getSSLParameters();
+ params.setNamedGroups(new String[] { namedGroup });
+ serverSocket.setSSLParameters(params);
+ return serverSocket;
+ }
+
+ /**
+ * Connects the client to the server socket, which accepts the connection
and completes the TLS handshake on the
+ * calling thread. Fails with an ExecutionException when the handshake of
the client fails.
+ */
+ private static void connect(NetClient client, SSLServerSocket
serverSocket) throws Exception {
+ Future<NetSocket> connected
+ = client.connect(serverSocket.getLocalPort(),
serverSocket.getInetAddress().getHostAddress());
+ serverSocket.setSoTimeout(10000);
+ try (SSLSocket accepted = (SSLSocket) serverSocket.accept()) {
+ accepted.setSoTimeout(10000);
+ try {
+ accepted.startHandshake();
+ } catch (SSLException e) {
+ // the client reports it too
+ }
+ result(connected).close();
+ }
+ }
+
+ private static <T> T result(Future<T> future) throws Exception {
+ return future.toCompletionStage().toCompletableFuture().get(30,
TimeUnit.SECONDS);
+ }
+}
diff --git
a/components/camel-vertx/camel-vertx-common/src/test/resources/jsse/service.jks
b/components/camel-vertx/camel-vertx-common/src/test/resources/jsse/service.jks
new file mode 100644
index 000000000000..52321ad965a1
Binary files /dev/null and
b/components/camel-vertx/camel-vertx-common/src/test/resources/jsse/service.jks
differ
diff --git
a/components/camel-vertx/camel-vertx-common/src/test/resources/log4j2.properties
b/components/camel-vertx/camel-vertx-common/src/test/resources/log4j2.properties
new file mode 100644
index 000000000000..4c3b95cfc4c8
--- /dev/null
+++
b/components/camel-vertx/camel-vertx-common/src/test/resources/log4j2.properties
@@ -0,0 +1,25 @@
+## ---------------------------------------------------------------------------
+## 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.
+## ---------------------------------------------------------------------------
+
+appender.out.type = File
+appender.out.name = out
+appender.out.fileName = target/camel-vertx-common-test.log
+appender.out.layout.type = PatternLayout
+appender.out.layout.pattern = %d [%-15.15t] %-5p %-30.30c{1} - %m%n
+
+rootLogger.level = INFO
+rootLogger.appenderRef.out.ref = out
diff --git
a/components/camel-vertx/camel-vertx-http/src/main/docs/vertx-http-component.adoc
b/components/camel-vertx/camel-vertx-http/src/main/docs/vertx-http-component.adoc
index 39655215ce68..bfaa1bf2c790 100644
---
a/components/camel-vertx/camel-vertx-http/src/main/docs/vertx-http-component.adoc
+++
b/components/camel-vertx/camel-vertx-http/src/main/docs/vertx-http-component.adoc
@@ -217,6 +217,10 @@ It is also possible to configure SSL options by providing
a custom `WebClientOpt
An `https://` address is always called with TLS. When no
`sslContextParameters` is configured, the server certificate
is checked with the default trust store of the JVM.
+Vert.x creates its own TLS engine from the `sslContextParameters`: the key and
trust managers, the cipher suites, the
+protocols and the named groups (including the post-quantum preference of
`SSLContextParameters`) are applied. Vert.x has
+no setting for the signature schemes, which are not applied, and a `WARN` is
logged when they are configured.
+
=== Session Management
Session management can be enabled via the `sessionManagement` URI option. When
enabled, an in-memory cookie store is used to track cookies.
diff --git
a/components/camel-vertx/camel-vertx-websocket/src/main/docs/vertx-websocket-component.adoc
b/components/camel-vertx/camel-vertx-websocket/src/main/docs/vertx-websocket-component.adoc
index 477be310f3bd..7c83b54afbac 100644
---
a/components/camel-vertx/camel-vertx-websocket/src/main/docs/vertx-websocket-component.adoc
+++
b/components/camel-vertx/camel-vertx-websocket/src/main/docs/vertx-websocket-component.adoc
@@ -373,3 +373,8 @@ via the `sslContextParameters` URI parameter and the
xref:manual::camel-configur
All consumers on the same host and port are served by one HTTP server, so they
must use the same `sslContextParameters`
instance. A consumer whose `sslContextParameters` differ from those of the
consumers already started on its host and
port fails to start.
+
+Vert.x creates its own TLS engine from the `sslContextParameters`: the key and
trust managers, the client
+authentication, the cipher suites, the protocols and the named groups
(including the post-quantum preference of
+`SSLContextParameters`) are applied. Vert.x has no setting for the signature
schemes, which are not applied, and a
+`WARN` is logged when they are configured.
diff --git
a/core/camel-api/src/main/java/org/apache/camel/support/jsse/JsseParametersHelper.java
b/core/camel-api/src/main/java/org/apache/camel/support/jsse/JsseParametersHelper.java
new file mode 100644
index 000000000000..46f13896a48e
--- /dev/null
+++
b/core/camel-api/src/main/java/org/apache/camel/support/jsse/JsseParametersHelper.java
@@ -0,0 +1,115 @@
+/*
+ * 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.support.jsse;
+
+import java.security.GeneralSecurityException;
+import java.util.ArrayList;
+import java.util.List;
+
+import javax.net.ssl.SSLContext;
+import javax.net.ssl.SSLEngine;
+
+import org.apache.camel.CamelContext;
+import org.jspecify.annotations.Nullable;
+
+/**
+ * Helps the components that map {@link SSLContextParameters} onto a TLS stack
of their own, such as the {@code ssl.*}
+ * properties of the Kafka client, instead of using the {@link SSLContext} of
+ * {@link SSLContextParameters#createSSLContext(CamelContext)}.
+ * <p>
+ * Only that {@code SSLContext} applies the options that live on the {@link
SSLEngine} and the {@code SSLSocket}: the
+ * named groups, the signature schemes, and the post-quantum preference of the
named groups that it applies when none
+ * are configured. A component that cannot carry them uses this helper to say
so, instead of dropping them in silence.
+ *
+ * @since 4.24
+ */
+public final class JsseParametersHelper {
+
+ private JsseParametersHelper() {
+ }
+
+ /**
+ * The options configured on the given parameters that only the {@code
SSLContext} of
+ * {@link SSLContextParameters#createSSLContext(CamelContext)} applies, so
a component that hands the key and trust
+ * material to a TLS stack of its own loses them: {@code namedGroups},
{@code namedGroupsFilter},
+ * {@code signatureSchemes} and {@code signatureSchemesFilter}.
+ * <p>
+ * The post-quantum preference that {@code createSSLContext} applies when
no named groups are configured is not an
+ * option of the user and is not listed; see {@link
#postQuantumNamedGroups(SSLContextParameters)}.
+ *
+ * @param parameters the SSL configuration
+ * @return the names of the configured options, in that order,
or an empty list when none is configured
+ */
+ public static List<String> engineOnlyParameters(SSLContextParameters
parameters) {
+ List<String> answer = new ArrayList<>(4);
+ if (parameters.getNamedGroups() != null) {
+ answer.add("namedGroups");
+ }
+ if (parameters.getNamedGroupsFilter() != null) {
+ answer.add("namedGroupsFilter");
+ }
+ if (parameters.getSignatureSchemes() != null) {
+ answer.add("signatureSchemes");
+ }
+ if (parameters.getSignatureSchemesFilter() != null) {
+ answer.add("signatureSchemesFilter");
+ }
+ return answer;
+ }
+
+ /**
+ * The named group order that {@link
SSLContextParameters#createSSLContext(CamelContext)} would apply on this JVM to
+ * prefer the post-quantum hybrid groups, as the named groups of the given
parameters are not configured.
+ * <p>
+ * The named groups of the JVM are read from its default {@code
SSLContext}.
+ *
+ * @param parameters the SSL configuration
+ * @return the order, or {@code null} when the parameters
configure the named groups, or when the JVM
+ * offers no post-quantum group or already leads with
one, in which case there is no preference
+ * to lose
+ */
+ public static @Nullable List<String>
postQuantumNamedGroups(SSLContextParameters parameters) {
+ if (parameters.getNamedGroups() != null ||
parameters.getNamedGroupsFilter() != null) {
+ return null;
+ }
+ String[] available;
+ try {
+ available =
SSLContext.getDefault().getDefaultSSLParameters().getNamedGroups();
+ } catch (GeneralSecurityException e) {
+ return null;
+ }
+ return postQuantumNamedGroups(available);
+ }
+
+ /**
+ * Orders the given named groups so that the post-quantum hybrids come
first, followed by the classical fallbacks
+ * and then everything else, preserving the spelling of the JVM. This is
the order that
+ * {@link SSLContextParameters#createSSLContext(CamelContext)} applies
when no named groups are configured, for a
+ * component that creates its {@link SSLEngine} without {@link
SSLContextParameters}.
+ * <p>
+ * An order that already leads with a hybrid is left alone: it is either
the default of the JVM or one an operator
+ * chose through {@code jdk.tls.namedGroups}, which must not be rewritten.
+ *
+ * @param availableGroups the named groups the JVM offers, in its order,
such as from
+ * {@code SSLParameters.getNamedGroups()}
+ * @return the preferred order, or {@code null} when the
JVM offers no post-quantum group or already
+ * leads with one, in which case the order is to
be left alone
+ */
+ public static @Nullable List<String> postQuantumNamedGroups(String
@Nullable [] availableGroups) {
+ return SSLContextParameters.resolvePqcNamedGroups(availableGroups);
+ }
+}
diff --git
a/core/camel-core/src/test/java/org/apache/camel/support/jsse/JsseParametersHelperTest.java
b/core/camel-core/src/test/java/org/apache/camel/support/jsse/JsseParametersHelperTest.java
new file mode 100644
index 000000000000..0d0bafd9b58e
--- /dev/null
+++
b/core/camel-core/src/test/java/org/apache/camel/support/jsse/JsseParametersHelperTest.java
@@ -0,0 +1,109 @@
+/*
+ * 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.support.jsse;
+
+import java.util.List;
+
+import javax.net.ssl.SSLContext;
+
+import org.junit.jupiter.api.Test;
+
+import static org.assertj.core.api.Assertions.assertThat;
+
+/**
+ * The options of {@link SSLContextParameters} that a component loses when it
hands the key and trust material to a TLS
+ * stack of its own instead of using the {@link SSLContext} of {@code
createSSLContext}.
+ */
+public class JsseParametersHelperTest {
+
+ @Test
+ public void testNoEngineOnlyParameters() {
+ SSLContextParameters scp = new SSLContextParameters();
+ scp.setCipherSuites(new CipherSuitesParameters());
+ scp.setSecureSocketProtocol("TLSv1.3");
+
+ assertThat(JsseParametersHelper.engineOnlyParameters(scp)).isEmpty();
+ }
+
+ @Test
+ public void testEngineOnlyParameters() {
+ SSLContextParameters scp = new SSLContextParameters();
+ NamedGroupsParameters ngp = new NamedGroupsParameters();
+ ngp.setNamedGroup(List.of("secp384r1"));
+ scp.setNamedGroups(ngp);
+ scp.setSignatureSchemesFilter(new FilterParameters());
+
+
assertThat(JsseParametersHelper.engineOnlyParameters(scp)).containsExactly("namedGroups",
"signatureSchemesFilter");
+
+ scp.setNamedGroupsFilter(new FilterParameters());
+ SignatureSchemesParameters ssp = new SignatureSchemesParameters();
+ ssp.setSignatureScheme(List.of("ed25519"));
+ scp.setSignatureSchemes(ssp);
+
+ assertThat(JsseParametersHelper.engineOnlyParameters(scp))
+ .containsExactly("namedGroups", "namedGroupsFilter",
"signatureSchemes", "signatureSchemesFilter");
+ }
+
+ @Test
+ public void testPostQuantumNamedGroupsOrder() {
+ // the same order as createSSLContext applies: the hybrids, the
classical fallbacks, then the rest of the JVM
+ assertThat(JsseParametersHelper.postQuantumNamedGroups(
+ new String[] { "x25519", "secp256r1", "SecP256r1MLKEM768",
"X25519MLKEM768", "secp384r1", "ffdhe2048" }))
+ .containsExactly("X25519MLKEM768", "SecP256r1MLKEM768",
"x25519", "secp256r1", "secp384r1", "ffdhe2048");
+ }
+
+ @Test
+ public void testPostQuantumNamedGroupsLeavesTheOrderAlone() {
+ // already leads with a hybrid, such as the default of JDK 27 or a
CNSA 2.0 order set by jdk.tls.namedGroups
+ assertThat(JsseParametersHelper.postQuantumNamedGroups(new String[] {
"SecP384r1MLKEM1024", "secp384r1" })).isNull();
+ // no hybrid on offer
+ assertThat(JsseParametersHelper.postQuantumNamedGroups(new String[] {
"x25519", "secp256r1" })).isNull();
+ assertThat(JsseParametersHelper.postQuantumNamedGroups((String[])
null)).isNull();
+ }
+
+ @Test
+ public void testPostQuantumNamedGroupsOfConfiguredNamedGroups() {
+ SSLContextParameters scp = new SSLContextParameters();
+ NamedGroupsParameters ngp = new NamedGroupsParameters();
+ ngp.setNamedGroup(List.of("x25519", "X25519MLKEM768"));
+ scp.setNamedGroups(ngp);
+ assertThat(JsseParametersHelper.postQuantumNamedGroups(scp)).isNull();
+
+ scp = new SSLContextParameters();
+ scp.setNamedGroupsFilter(new FilterParameters());
+ assertThat(JsseParametersHelper.postQuantumNamedGroups(scp)).isNull();
+ }
+
+ @Test
+ public void testPostQuantumNamedGroupsMatchCreateSSLContext() throws
Exception {
+ SSLContext plain = SSLContext.getInstance("TLS");
+ plain.init(null, null, null);
+ String[] jvmGroups = plain.getDefaultSSLParameters().getNamedGroups();
+
+ SSLContextParameters scp = new SSLContextParameters();
+ List<String> expected =
JsseParametersHelper.postQuantumNamedGroups(scp);
+ String[] applied =
scp.createSSLContext(null).createSSLEngine().getSSLParameters().getNamedGroups();
+
+ // whatever this JVM offers: the order the helper reports is the one
createSSLContext applies, and when it
+ // reports none, createSSLContext keeps the order of the JVM
+ if (expected != null) {
+ assertThat(applied).containsExactlyElementsOf(expected);
+ } else {
+ assertThat(applied).isEqualTo(jvmGroups);
+ }
+ }
+}
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 3afb5e0524cc..1f4a4d479f60 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
@@ -656,6 +656,22 @@ all `https://` addresses.
A route that called an `https://` address of a server that only speaks plain
HTTP now fails; use an `http://` address
for such a server. An `http://` address with `sslContextParameters` is not
changed.
+=== camel-platform-http-vertx, camel-vertx-http, camel-vertx-websocket,
camel-vertx-mqtt, camel-apicurio-registry, camel-kafka, camel-thrift - the
named groups of sslContextParameters
+
+The Vert.x components (`camel-platform-http-vertx`, `camel-vertx-http`,
`camel-vertx-websocket` and
+`camel-vertx-mqtt`) and `camel-apicurio-registry` now apply the `namedGroups`
(or `namedGroupsFilter`) of
+`sslContextParameters` to their TLS connections, as the key exchange groups of
Vert.x. Before, they were ignored. When no named groups are configured, the
+post-quantum preference that `SSLContextParameters` applies on a JVM that
offers a hybrid group but does not lead with
+one is applied as well. A peer that only supports named groups outside of the
configured ones can no longer connect.
+Vert.x has no setting for the signature schemes: a `WARN` is logged when
`signatureSchemes` are configured.
+
+The Kafka client (`camel-kafka`, `camel-kafka-share`) and the `camel-thrift`
producer cannot apply the named groups
+and the signature schemes of `sslContextParameters`, as they create their TLS
connections from settings of their own.
+They still ignore them, as before, but now log a `WARN` when they start with
them configured. To apply them, set
+the `jdk.tls.namedGroups`, `jdk.tls.client.SignatureSchemes` and
`jdk.tls.server.SignatureSchemes` system properties
+of the JDK. See _Components with their own TLS stack_ in the
+xref:camel-configuration-utilities.adoc#_components_with_their_own_tls_stack[Camel
JSSE Configuration Utility].
+
=== camel-openfga - writeTuples and the read operations carry a relationship
condition
`writeTuples` now honours a relationship condition set on a tuple in the
message body: a `ClientTupleKey` built with
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 9d65afd6a42b..f72827799328 100644
--- a/docs/user-manual/modules/ROOT/pages/camel-configuration-utilities.adoc
+++ b/docs/user-manual/modules/ROOT/pages/camel-configuration-utilities.adoc
@@ -477,8 +477,9 @@ System.out.println(Arrays.toString(groups));
=== Auto-Configuration (Zero-Config PQC)
When running on a JDK that enables a hybrid ML-KEM group (`X25519MLKEM768`,
`SecP256r1MLKEM768` or
-`SecP384r1MLKEM1024`), Camel *automatically* prefers it on all
`SSLContextParameters` instances, without
-any configuration.
+`SecP384r1MLKEM1024`), Camel *automatically* prefers it in the `SSLContext`
that it creates from
+`SSLContextParameters`, without any configuration. A few components do not use
that `SSLContext`, see
+<<_components_with_their_own_tls_stack>>.
The auto-configuration activates only when:
@@ -512,6 +513,41 @@ A `DEBUG` message of
`org.apache.camel.support.jsse.SSLContextParameters` says s
enables no hybrid group at all. To verify which key exchange is preferred,
read the named groups of a created
`SSLEngine` or `SSLSocket` as shown above.
+=== Components with their own TLS stack
+
+The named groups, the signature schemes and the post-quantum preference are
settings of the `SSLEngine` and the
+`SSLSocket`, which only the `SSLContext` created by
`SSLContextParameters.createSSLContext()` applies. Most components
+use that `SSLContext`, and honour all the settings. A few hand the key and
trust material to a TLS stack of their own
+instead, which applies only part of them:
+
+[cols="1,2,2",options="header"]
+|===
+| Component | Applied | Not applied
+
+| camel-platform-http-vertx, camel-vertx-http, camel-vertx-websocket,
camel-vertx-mqtt, camel-apicurio-registry
+| The key and trust managers, the client authentication, the cipher suites,
the protocols, and the named groups,
+including the post-quantum preference, as the key exchange groups of Vert.x
+| The signature schemes: Vert.x has no such setting, and a `WARN` says so when
they are configured
+
+| camel-kafka, camel-kafka-share
+| The protocol, the provider, the cipher suites, the enabled protocols and the
key and trust stores, as `ssl.*`
+properties of the Kafka client
+| The named groups and the signature schemes, as the Kafka client has no such
properties: a `WARN` says so when they
+are configured. The post-quantum preference is not applied either, and the
client uses the named group order of the
+JVM; as this is not a setting of the user, a `DEBUG` message of
`org.apache.camel.component.kafka.KafkaClientConfiguration`
+says so
+
+| camel-thrift (producer)
+| The protocol, the cipher suites and the trust store
+| The named groups and the signature schemes, with a `WARN` when they are
configured, and the post-quantum preference,
+with a `DEBUG` message. The consumer uses the `SSLContext` and applies all the
settings
+|===
+
+To apply named groups or signature schemes to such a component anyway, set
them for the whole JVM with the
+`jdk.tls.namedGroups`, `jdk.tls.client.SignatureSchemes` and
`jdk.tls.server.SignatureSchemes` system properties of
+the JDK, which every TLS connection of the JVM uses. On a JDK that leads with
a hybrid group by default, such as
+JDK 27, the post-quantum key exchange is preferred by these components as
well, since that is the order of the JVM.
+
=== Explicit Configuration via application.properties
You can explicitly control PQC TLS settings in `application.properties`:
diff --git a/docs/user-manual/modules/ROOT/pages/security.adoc
b/docs/user-manual/modules/ROOT/pages/security.adoc
index a046393e4736..a9abd64022c9 100644
--- a/docs/user-manual/modules/ROOT/pages/security.adoc
+++ b/docs/user-manual/modules/ROOT/pages/security.adoc
@@ -71,11 +71,15 @@ components.
Camel provides Post-Quantum Cryptography (PQC) protection at two complementary
layers:
-* *Transport layer (TLS).* On JDK 25+, Camel automatically configures hybrid
post-quantum key
-exchange (`X25519MLKEM768`) on all `SSLContextParameters` to protect
connections against
-harvest-now-decrypt-later attacks. See
+* *Transport layer (TLS).* On a JDK that offers a hybrid post-quantum key
exchange group such as
+`X25519MLKEM768`, the `SSLContext` that Camel creates from
`SSLContextParameters` prefers it, to protect
+connections against harvest-now-decrypt-later attacks. This applies to the
components that use that `SSLContext`;
+a few components hand the key and trust material to a TLS stack of their own,
which applies only part of the
+settings. See
xref:camel-configuration-utilities.adoc#_post_quantum_cryptography_pqc_tls_configuration[PQC
TLS Configuration]
-for the full configuration guide.
+for the full configuration guide and
+xref:camel-configuration-utilities.adoc#_components_with_their_own_tls_stack[Components
with their own TLS stack]
+for what each of those components honours.
* *Message layer.* The xref:components::pqc-component.adoc[PQC component] and
xref:components:dataformats:pqc-dataformat.adoc[PQC data format] encrypt and
sign message
payloads using post-quantum algorithms (ML-KEM, ML-DSA, SLH-DSA, and more),
protecting data