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 2db093dd26e8 CAMEL-27582: Fix ThriftProducer SSL key managers for mTLS 
client certificate auth (#30923)
2db093dd26e8 is described below

commit 2db093dd26e822138ba73aa428cbcf89304dabdd
Author: Guillaume Nodet <[email protected]>
AuthorDate: Sat Nov 28 10:14:06 2026 +0100

    CAMEL-27582: Fix ThriftProducer SSL key managers for mTLS client 
certificate auth (#30923)
    
    ThriftProducer.initializeSslTransport() built its TLS connection from
    TSSLTransportFactory.TSSLTransportParameters, which only supports trust
    store configuration and cannot use the key managers, cipher suites or
    named groups of sslContextParameters. This made mTLS (client certificate
    authentication) impossible for the Thrift producer.
    
    The producer now builds its socket from 
SSLContextParameters.createSSLContext(),
    which applies all SSL settings (key managers, trust managers, protocols,
    cipher suites, named groups, signature schemes), and wraps the SSLSocket in 
a
    TSocket, as ThriftConsumer already did. Hostname verification is kept with
    setEndpointIdentificationAlgorithm("HTTPS"), and the socket is closed when
    its setup fails. ThriftProducerClientAuthenticationTest covers mTLS and
    ThriftProducerHostnameVerificationTest the host name check. The component
    doc, the TLS utilities page and the 4.24 upgrade guide are updated.
    
    AI-generated by Hermes Agent (Claude Sonnet 4.6) on behalf of Guillaume 
Nodet.
    
    Co-authored-by: Claude Sonnet 4.6 <[email protected]>
    Co-authored-by: Claude Opus 5.5 <[email protected]>
---
 .../camel/catalog/docs/thrift-component.adoc       |  30 +++-
 .../src/main/docs/thrift-component.adoc            |  30 +++-
 .../camel/component/thrift/ThriftProducer.java     |  95 +++++------
 .../ThriftProducerClientAuthenticationTest.java    | 175 +++++++++++++++++++++
 .../ThriftProducerHostnameVerificationTest.java    | 167 ++++++++++++++++++++
 .../thrift/ThriftProducerSslOptionsTest.java       | 155 ------------------
 .../ROOT/pages/camel-4x-upgrade-guide-4_24.adoc    |  23 ++-
 .../ROOT/pages/camel-configuration-utilities.adoc  |   5 -
 8 files changed, 451 insertions(+), 229 deletions(-)

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 df4dbc8bff33..add1f52cc076 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,11 +194,31 @@ 
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].
+The producer builds its TLS connection from the full SSL context of 
`sslParameters`, the same as the consumer. All
+SSL settings apply: the key managers (client certificate for mTLS), trust 
managers, protocols, cipher suites, named
+groups, signature schemes and the post-quantum preference. Without trust 
managers, the JVM default trust store is used.
+The producer verifies that the server certificate matches the host name of the 
URI.
+
+For mTLS (the producer sends a client certificate), configure the key managers 
of `sslParameters` with the client
+certificate and key, and the trust managers with the CA that signed the server 
certificate, and add
+`synchronous=true`:
+
+[source,java]
+----
+KeyManagersParameters keyManagers = new KeyManagersParameters();
+keyManagers.setKeyStore(keyStore);
+keyManagers.setKeyPassword("keyPassword");
+
+TrustManagersParameters trustManagers = new TrustManagersParameters();
+trustManagers.setKeyStore(trustStore);
+
+SSLContextParameters sslParameters = new SSLContextParameters();
+sslParameters.setKeyManagers(keyManagers);
+sslParameters.setTrustManagers(trustManagers);
+context.getRegistry().bind("sslParams", sslParameters);
+
+to("thrift://server:9090/org.example.Calculator?negotiationType=SSL&sslParameters=#sslParams&synchronous=true");
+----
 
 == Errors sent to the client
 
diff --git a/components/camel-thrift/src/main/docs/thrift-component.adoc 
b/components/camel-thrift/src/main/docs/thrift-component.adoc
index df4dbc8bff33..add1f52cc076 100644
--- a/components/camel-thrift/src/main/docs/thrift-component.adoc
+++ b/components/camel-thrift/src/main/docs/thrift-component.adoc
@@ -194,11 +194,31 @@ 
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].
+The producer builds its TLS connection from the full SSL context of 
`sslParameters`, the same as the consumer. All
+SSL settings apply: the key managers (client certificate for mTLS), trust 
managers, protocols, cipher suites, named
+groups, signature schemes and the post-quantum preference. Without trust 
managers, the JVM default trust store is used.
+The producer verifies that the server certificate matches the host name of the 
URI.
+
+For mTLS (the producer sends a client certificate), configure the key managers 
of `sslParameters` with the client
+certificate and key, and the trust managers with the CA that signed the server 
certificate, and add
+`synchronous=true`:
+
+[source,java]
+----
+KeyManagersParameters keyManagers = new KeyManagersParameters();
+keyManagers.setKeyStore(keyStore);
+keyManagers.setKeyPassword("keyPassword");
+
+TrustManagersParameters trustManagers = new TrustManagersParameters();
+trustManagers.setKeyStore(trustStore);
+
+SSLContextParameters sslParameters = new SSLContextParameters();
+sslParameters.setKeyManagers(keyManagers);
+sslParameters.setTrustManagers(trustManagers);
+context.getRegistry().bind("sslParams", sslParameters);
+
+to("thrift://server:9090/org.example.Calculator?negotiationType=SSL&sslParameters=#sslParams&synchronous=true");
+----
 
 == Errors sent to the client
 
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 e98636378bf7..91cd0b547d8c 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,11 +17,15 @@
 package org.apache.camel.component.thrift;
 
 import java.io.IOException;
-import java.util.List;
+import java.security.GeneralSecurityException;
 import java.util.Set;
 import java.util.concurrent.ConcurrentHashMap;
 import java.util.concurrent.atomic.AtomicBoolean;
 
+import javax.net.ssl.SSLContext;
+import javax.net.ssl.SSLParameters;
+import javax.net.ssl.SSLSocket;
+
 import org.apache.camel.AsyncCallback;
 import org.apache.camel.AsyncProducer;
 import org.apache.camel.CamelExchangeException;
@@ -29,15 +33,13 @@ import org.apache.camel.Exchange;
 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.IOHelper;
 import org.apache.camel.util.ObjectHelper;
 import org.apache.thrift.TException;
 import org.apache.thrift.async.TAsyncClientManager;
 import org.apache.thrift.transport.TNonblockingSocket;
 import org.apache.thrift.transport.TNonblockingTransport;
-import org.apache.thrift.transport.TSSLTransportFactory;
 import org.apache.thrift.transport.TSocket;
 import org.apache.thrift.transport.TTransport;
 import org.apache.thrift.transport.TTransportException;
@@ -287,62 +289,49 @@ public class ThriftProducer extends DefaultAsyncProducer 
implements AsyncProduce
                                                    + 
configuration.getNegotiationType());
             }
 
-            ObjectHelper.notNull(sslParameters.getSecureSocketProtocol(), 
"Security protocol");
-            
ObjectHelper.notNull(sslParameters.getTrustManagers().getKeyStore().getResource(),
 "Trust store path");
-            
ObjectHelper.notNull(sslParameters.getTrustManagers().getKeyStore().getPassword(),
 "Trust store password");
-
             LOG.info("Creating secured transport to the remote Thrift server 
{}:{}", configuration.getHost(),
                     configuration.getPort());
 
-            logDroppedSslOptions(sslParameters);
-
-            TSSLTransportFactory.TSSLTransportParameters sslParams;
-
-            sslParams = new TSSLTransportFactory.TSSLTransportParameters(
-                    sslParameters.getSecureSocketProtocol(),
-                    sslParameters.getCipherSuites() == null
-                            ? null
-                            : 
sslParameters.getCipherSuites().getCipherSuite().stream().toArray(String[]::new));
-
-            if 
(ObjectHelper.isNotEmpty(sslParameters.getTrustManagers().getProvider())
-                    && 
ObjectHelper.isNotEmpty(sslParameters.getTrustManagers().getKeyStore().getType()))
 {
-                sslParams.setTrustStore(
-                        
ResourceHelper.resolveResourceAsInputStream(endpoint.getCamelContext(),
-                                
sslParameters.getTrustManagers().getKeyStore().getResource()),
-                        
sslParameters.getTrustManagers().getKeyStore().getPassword(),
-                        sslParameters.getTrustManagers().getProvider(),
-                        
sslParameters.getTrustManagers().getKeyStore().getType());
-            } else {
-                
sslParams.setTrustStore(sslParameters.getTrustManagers().getKeyStore().getResource(),
-                        
sslParameters.getTrustManagers().getKeyStore().getPassword());
+            // Use the full SSLContext from sslParameters so that all SSL 
settings are applied: key managers
+            // (client certificate for mTLS), trust managers, protocols, 
cipher suites and named groups.
+            // This mirrors the approach used by 
ThriftConsumer.initializeServer().
+            SSLContext sslContext;
+            try {
+                sslContext = 
sslParameters.createSSLContext(endpoint.getCamelContext());
+            } catch (GeneralSecurityException e) {
+                throw new IllegalArgumentException(
+                        "Unable to create the SSL context for the Thrift 
producer"
+                                                   + 
(sslParameters.getKeyManagers() != null
+                                                           && 
sslParameters.getKeyManagers().getKeyPassword() == null
+                                                                   ? " (set 
keyPassword on the key managers of sslParameters"
+                                                                     + " when 
the key is protected by a password)"
+                                                                   : ""),
+                        e);
             }
 
-            syncTransport = 
TSSLTransportFactory.getClientSocket(configuration.getHost(), 
configuration.getPort(),
-                    configuration.getClientTimeout(), sslParams);
+            SSLSocket sslSocket;
+            try {
+                sslSocket = (SSLSocket) sslContext.getSocketFactory()
+                        .createSocket(configuration.getHost(), 
configuration.getPort());
+            } catch (IOException e) {
+                throw new TTransportException(
+                        "Unable to open SSL connection to " + 
configuration.getHost() + ":" + configuration.getPort(), e);
+            }
+            try {
+                // Apply hostname verification, as TSSLTransportFactory does 
since libthrift 0.23.0.
+                SSLParameters socketParameters = sslSocket.getSSLParameters();
+                socketParameters.setEndpointIdentificationAlgorithm("HTTPS");
+                sslSocket.setSSLParameters(socketParameters);
+                if (configuration.getClientTimeout() > 0) {
+                    sslSocket.setSoTimeout(configuration.getClientTimeout());
+                }
+                syncTransport = new TSocket(sslSocket);
+            } catch (IOException | TTransportException e) {
+                IOHelper.close(sslSocket);
+                throw e;
+            }
         } else {
             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/ThriftProducerClientAuthenticationTest.java
 
b/components/camel-thrift/src/test/java/org/apache/camel/component/thrift/ThriftProducerClientAuthenticationTest.java
new file mode 100644
index 000000000000..286353dbafb8
--- /dev/null
+++ 
b/components/camel-thrift/src/test/java/org/apache/camel/component/thrift/ThriftProducerClientAuthenticationTest.java
@@ -0,0 +1,175 @@
+/*
+ * 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.security.KeyStore;
+import java.util.ArrayList;
+import java.util.List;
+
+import javax.net.ssl.KeyManagerFactory;
+import javax.net.ssl.SSLContext;
+import javax.net.ssl.SSLServerSocket;
+import javax.net.ssl.TrustManagerFactory;
+
+import org.apache.camel.builder.RouteBuilder;
+import org.apache.camel.component.thrift.generated.Calculator;
+import org.apache.camel.component.thrift.generated.Operation;
+import org.apache.camel.component.thrift.generated.Work;
+import org.apache.camel.component.thrift.impl.CalculatorSyncServerImpl;
+import org.apache.camel.spi.Registry;
+import org.apache.camel.support.jsse.KeyManagersParameters;
+import org.apache.camel.support.jsse.KeyStoreParameters;
+import org.apache.camel.support.jsse.SSLContextParameters;
+import org.apache.camel.support.jsse.TrustManagersParameters;
+import org.apache.camel.test.junit6.CamelTestSupport;
+import org.apache.thrift.server.TServer;
+import org.apache.thrift.server.TThreadPoolServer;
+import org.apache.thrift.transport.TServerSocket;
+import org.junit.jupiter.api.Test;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+import static org.junit.jupiter.api.Assertions.assertEquals;
+import static org.junit.jupiter.api.Assertions.assertNotNull;
+import static org.junit.jupiter.api.Assertions.assertTrue;
+
+/**
+ * Tests that the SSL producer applies the key managers of 
sslContextParameters so that it can authenticate with a
+ * client certificate (mTLS). The server requires a client certificate; a 
producer without key managers would fail the
+ * TLS handshake.
+ */
+class ThriftProducerClientAuthenticationTest extends CamelTestSupport {
+
+    private static final Logger LOG = 
LoggerFactory.getLogger(ThriftProducerClientAuthenticationTest.class);
+
+    private static final String KEY_STORE_RESOURCE = 
"src/test/resources/certs/keystore.jks";
+    private static final String TRUST_STORE_RESOURCE = 
"src/test/resources/certs/truststore.jks";
+    private static final String KEY_STORE_FILE_RESOURCE = "file:" + 
KEY_STORE_RESOURCE;
+    private static final String TRUST_STORE_FILE_RESOURCE = "file:" + 
TRUST_STORE_RESOURCE;
+    private static final String SECURITY_STORE_PASSWORD = "camelinaction";
+    private static final int THRIFT_CLIENT_TIMEOUT = 2000;
+    private static final int THRIFT_TEST_NUM1 = 12;
+    private static final int THRIFT_TEST_NUM2 = 13;
+
+    private TServerSocket serverTransport;
+    private TServer server;
+    private int thriftTestPort;
+
+    @Override
+    @SuppressWarnings({ "unchecked", "rawtypes" })
+    public void doPreSetup() throws Exception {
+        // Build an SSLContext that knows the server's key (for TLS) and the 
trust store (to verify client certs)
+        char[] password = SECURITY_STORE_PASSWORD.toCharArray();
+
+        KeyStore keyStore = KeyStore.getInstance("JKS");
+        try (var is = 
getClass().getClassLoader().getResourceAsStream("certs/keystore.jks")) {
+            keyStore.load(is, password);
+        }
+        KeyManagerFactory kmf = 
KeyManagerFactory.getInstance(KeyManagerFactory.getDefaultAlgorithm());
+        kmf.init(keyStore, password);
+
+        KeyStore trustStore = KeyStore.getInstance("JKS");
+        try (var is = 
getClass().getClassLoader().getResourceAsStream("certs/truststore.jks")) {
+            trustStore.load(is, password);
+        }
+        TrustManagerFactory tmf = 
TrustManagerFactory.getInstance(TrustManagerFactory.getDefaultAlgorithm());
+        tmf.init(trustStore);
+
+        SSLContext serverSslContext = SSLContext.getInstance("TLS");
+        serverSslContext.init(kmf.getKeyManagers(), tmf.getTrustManagers(), 
null);
+
+        // Create a server socket that requires the client to present a 
certificate (mTLS)
+        SSLServerSocket serverSocket = (SSLServerSocket) 
serverSslContext.getServerSocketFactory()
+                .createServerSocket(0, 100, 
InetAddress.getByName("localhost"));
+        serverSocket.setNeedClientAuth(true);
+        thriftTestPort = serverSocket.getLocalPort();
+
+        serverTransport = new TServerSocket(
+                new TServerSocket.ServerSocketTransportArgs()
+                        .serverSocket(serverSocket)
+                        .clientTimeout(THRIFT_CLIENT_TIMEOUT));
+
+        Calculator.Processor processor = new Calculator.Processor(new 
CalculatorSyncServerImpl());
+        TThreadPoolServer.Args args = new 
TThreadPoolServer.Args(serverTransport);
+        args.processor(processor);
+        server = new TThreadPoolServer(args);
+
+        new Thread(() -> {
+            LOG.info("Thrift mTLS server started on port: {}", thriftTestPort);
+            server.serve();
+        }).start();
+    }
+
+    @Override
+    protected void cleanupResources() throws Exception {
+        if (server != null) {
+            server.stop();
+            serverTransport.close();
+        }
+    }
+
+    @Override
+    protected void bindToRegistry(Registry registry) {
+        // Producer sslParameters with BOTH trust managers AND key managers 
(client certificate for mTLS)
+        KeyStoreParameters keyStore = new KeyStoreParameters();
+        keyStore.setResource(KEY_STORE_FILE_RESOURCE);
+        keyStore.setPassword(SECURITY_STORE_PASSWORD);
+        KeyManagersParameters keyManagers = new KeyManagersParameters();
+        keyManagers.setKeyStore(keyStore);
+        keyManagers.setKeyPassword(SECURITY_STORE_PASSWORD);
+
+        KeyStoreParameters trustStore = new KeyStoreParameters();
+        trustStore.setResource(TRUST_STORE_FILE_RESOURCE);
+        trustStore.setPassword(SECURITY_STORE_PASSWORD);
+        TrustManagersParameters trustManagers = new TrustManagersParameters();
+        trustManagers.setKeyStore(trustStore);
+
+        SSLContextParameters sslParameters = new SSLContextParameters();
+        sslParameters.setKeyManagers(keyManagers);
+        sslParameters.setTrustManagers(trustManagers);
+
+        registry.bind("sslParams", sslParameters);
+    }
+
+    @Test
+    @SuppressWarnings({ "rawtypes", "unchecked" })
+    void producerWithClientCertificateIsServedByMtlsServer() {
+        List requestBody = new ArrayList();
+        requestBody.add(1);
+        requestBody.add(new Work(THRIFT_TEST_NUM1, THRIFT_TEST_NUM2, 
Operation.MULTIPLY));
+
+        Object responseBody = 
template.requestBody("direct:thrift-mtls-calculate", requestBody);
+
+        assertNotNull(responseBody);
+        assertTrue(responseBody instanceof Integer);
+        assertEquals(THRIFT_TEST_NUM1 * THRIFT_TEST_NUM2, responseBody);
+    }
+
+    @Override
+    protected RouteBuilder createRouteBuilder() {
+        return new RouteBuilder() {
+            @Override
+            public void configure() {
+                from("direct:thrift-mtls-calculate")
+                        .to("thrift://localhost:" + thriftTestPort
+                            + 
"/org.apache.camel.component.thrift.generated.Calculator?"
+                            + 
"method=calculate&negotiationType=SSL&sslParameters=#sslParams&synchronous=true");
+            }
+        };
+    }
+}
diff --git 
a/components/camel-thrift/src/test/java/org/apache/camel/component/thrift/ThriftProducerHostnameVerificationTest.java
 
b/components/camel-thrift/src/test/java/org/apache/camel/component/thrift/ThriftProducerHostnameVerificationTest.java
new file mode 100644
index 000000000000..1ccedb7fa7c9
--- /dev/null
+++ 
b/components/camel-thrift/src/test/java/org/apache/camel/component/thrift/ThriftProducerHostnameVerificationTest.java
@@ -0,0 +1,167 @@
+/*
+ * 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.security.KeyStore;
+import java.util.ArrayList;
+import java.util.List;
+
+import javax.net.ssl.KeyManagerFactory;
+import javax.net.ssl.SSLContext;
+import javax.net.ssl.SSLHandshakeException;
+import javax.net.ssl.SSLServerSocket;
+import javax.net.ssl.TrustManagerFactory;
+
+import org.apache.camel.CamelExecutionException;
+import org.apache.camel.builder.RouteBuilder;
+import org.apache.camel.component.thrift.generated.Calculator;
+import org.apache.camel.component.thrift.generated.Operation;
+import org.apache.camel.component.thrift.generated.Work;
+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.SSLContextParameters;
+import org.apache.camel.support.jsse.TrustManagersParameters;
+import org.apache.camel.test.junit6.CamelTestSupport;
+import org.apache.camel.util.ObjectHelper;
+import org.apache.thrift.server.TServer;
+import org.apache.thrift.server.TThreadPoolServer;
+import org.apache.thrift.transport.TServerSocket;
+import org.junit.jupiter.api.Test;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+import static org.junit.jupiter.api.Assertions.assertNotNull;
+import static org.junit.jupiter.api.Assertions.assertThrows;
+
+/**
+ * Tests that the SSL producer enforces hostname verification. The test 
certificate is issued for {@code CN=localhost}
+ * with no Subject Alternative Name. A producer connecting to {@code 
thrift://127.0.0.1:<port>} must fail the TLS
+ * handshake because {@code 127.0.0.1} does not match {@code localhost}.
+ */
+class ThriftProducerHostnameVerificationTest extends CamelTestSupport {
+
+    private static final Logger LOG = 
LoggerFactory.getLogger(ThriftProducerHostnameVerificationTest.class);
+
+    private static final String TRUST_STORE_FILE_RESOURCE = 
"file:src/test/resources/certs/truststore.jks";
+    private static final String SECURITY_STORE_PASSWORD = "camelinaction";
+    private static final int THRIFT_CLIENT_TIMEOUT = 2000;
+
+    private TServerSocket serverTransport;
+    private TServer server;
+    private int thriftTestPort;
+
+    @Override
+    @SuppressWarnings({ "unchecked", "rawtypes" })
+    public void doPreSetup() throws Exception {
+        char[] password = SECURITY_STORE_PASSWORD.toCharArray();
+
+        KeyStore keyStore = KeyStore.getInstance("JKS");
+        try (var is = 
getClass().getClassLoader().getResourceAsStream("certs/keystore.jks")) {
+            keyStore.load(is, password);
+        }
+        KeyManagerFactory kmf = 
KeyManagerFactory.getInstance(KeyManagerFactory.getDefaultAlgorithm());
+        kmf.init(keyStore, password);
+
+        KeyStore trustStore = KeyStore.getInstance("JKS");
+        try (var is = 
getClass().getClassLoader().getResourceAsStream("certs/truststore.jks")) {
+            trustStore.load(is, password);
+        }
+        TrustManagerFactory tmf = 
TrustManagerFactory.getInstance(TrustManagerFactory.getDefaultAlgorithm());
+        tmf.init(trustStore);
+
+        SSLContext serverSslContext = SSLContext.getInstance("TLS");
+        serverSslContext.init(kmf.getKeyManagers(), tmf.getTrustManagers(), 
null);
+
+        // Server bound to 127.0.0.1, the address the producer connects to, so 
the connection always reaches
+        // the TLS handshake (localhost may resolve to ::1 first); the 
certificate is CN=localhost (no SAN)
+        SSLServerSocket serverSocket = (SSLServerSocket) 
serverSslContext.getServerSocketFactory()
+                .createServerSocket(0, 100, 
InetAddress.getByName("127.0.0.1"));
+        thriftTestPort = serverSocket.getLocalPort();
+
+        serverTransport = new TServerSocket(
+                new TServerSocket.ServerSocketTransportArgs()
+                        .serverSocket(serverSocket)
+                        .clientTimeout(THRIFT_CLIENT_TIMEOUT));
+
+        Calculator.Processor processor = new Calculator.Processor(new 
CalculatorSyncServerImpl());
+        TThreadPoolServer.Args args = new 
TThreadPoolServer.Args(serverTransport);
+        args.processor(processor);
+        server = new TThreadPoolServer(args);
+
+        new Thread(() -> {
+            LOG.info("Thrift SSL server started on port: {}", thriftTestPort);
+            server.serve();
+        }).start();
+    }
+
+    @Override
+    protected void cleanupResources() throws Exception {
+        if (server != null) {
+            server.stop();
+            serverTransport.close();
+        }
+    }
+
+    @Override
+    protected void bindToRegistry(Registry registry) {
+        // Trust store only — no key managers needed (not mTLS)
+        SSLContextParameters sslParameters = new SSLContextParameters();
+
+        KeyStoreParameters trustStoreParams = new KeyStoreParameters();
+        trustStoreParams.setResource(TRUST_STORE_FILE_RESOURCE);
+        trustStoreParams.setPassword(SECURITY_STORE_PASSWORD);
+
+        TrustManagersParameters trustManagers = new TrustManagersParameters();
+        trustManagers.setKeyStore(trustStoreParams);
+
+        sslParameters.setTrustManagers(trustManagers);
+
+        registry.bind("sslParams", sslParameters);
+    }
+
+    @Test
+    @SuppressWarnings({ "rawtypes", "unchecked" })
+    void producerConnectingByIpFailsHostnameVerification() {
+        // The server certificate is CN=localhost (no SAN). A producer using 
the IP address 127.0.0.1
+        // must fail the TLS handshake because the IP does not match the 
certificate's CN.
+        List requestBody = new ArrayList();
+        requestBody.add(1);
+        requestBody.add(new Work(12, 13, Operation.MULTIPLY));
+
+        CamelExecutionException e = assertThrows(CamelExecutionException.class,
+                () -> template.requestBody("direct:thrift-ip-calculate", 
requestBody),
+                "Expected TLS handshake failure when connecting by IP to a 
CN=localhost certificate");
+        assertNotNull(ObjectHelper.getException(SSLHandshakeException.class, 
e),
+                "Expected a TLS handshake failure (hostname mismatch), got: " 
+ e);
+    }
+
+    @Override
+    protected RouteBuilder createRouteBuilder() {
+        return new RouteBuilder() {
+            @Override
+            public void configure() {
+                // Connect by IP address — hostname verification must reject 
CN=localhost
+                from("direct:thrift-ip-calculate")
+                        .to("thrift://127.0.0.1:" + thriftTestPort
+                            + 
"/org.apache.camel.component.thrift.generated.Calculator?"
+                            + 
"method=calculate&negotiationType=SSL&sslParameters=#sslParams&synchronous=true");
+            }
+        };
+    }
+}
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
deleted file mode 100644
index ad3b5d9aff6c..000000000000
--- 
a/components/camel-thrift/src/test/java/org/apache/camel/component/thrift/ThriftProducerSslOptionsTest.java
+++ /dev/null
@@ -1,155 +0,0 @@
-/*
- * 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/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 f5553137a976..79b27106fa18 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
@@ -753,7 +753,7 @@ 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
+=== camel-platform-http-vertx, camel-vertx-http, camel-vertx-websocket, 
camel-vertx-mqtt, camel-apicurio-registry, camel-kafka - 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
@@ -762,11 +762,11 @@ post-quantum preference that `SSLContextParameters` 
applies on a JVM that offers
 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
+The Kafka client (`camel-kafka`, `camel-kafka-share`) cannot apply the named 
groups and the signature schemes of
+`sslContextParameters`, as it creates its TLS connections from settings of its 
own. It still ignores them, as before,
+but now logs a `WARN` when it starts 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
@@ -5914,6 +5914,17 @@ on the component 
(`camel.component.keycloak.allowOperationHeader=true`) for all
 An endpoint without an `operation`, which took the operation from the header, 
now fails with an
 `IllegalArgumentException` that asks for the operation, unless it sets 
`allowOperationHeader=true`.
 
+=== camel-thrift - SSL/TLS settings of the producer
+
+* The SSL/TLS producer now builds its client socket from the full SSL context 
of `sslParameters`, the same as the
+  consumer. All SSL settings now apply: the key managers (client certificate 
for mTLS), trust managers, protocols,
+  cipher suites, named groups, signature schemes and the post-quantum 
preference. Before, the producer used
+  `TSSLTransportFactory` and only applied the protocol, cipher suites and 
trust store; the named groups and signature
+  schemes were ignored (with a `WARN`), and the key managers were never sent.
+* A `camel-thrift` producer without trust managers configured now uses the JVM 
default trust store. Before, it failed
+  to start with a `NullPointerException` on the missing trust store path.
+* The producer still verifies that the server certificate matches the host 
name of the URI, as before.
+
 === camel-thrift - SSL/TLS settings of the consumer, and errors sent to the 
client
 
 * A consumer configured with `negotiationType=SSL` and the default 
`synchronous=false` now fails to start. It used to
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 f72827799328..3a36de6daa77 100644
--- a/docs/user-manual/modules/ROOT/pages/camel-configuration-utilities.adoc
+++ b/docs/user-manual/modules/ROOT/pages/camel-configuration-utilities.adoc
@@ -536,11 +536,6 @@ properties of the Kafka client
 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

Reply via email to