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 c57d0d8cbc47 CAMEL-27229: camel-ftp - ftps checks the server 
certificate against the JVM trust store when no trust store is configured 
(#30373)
c57d0d8cbc47 is described below

commit c57d0d8cbc47bc10ebb00e409f56132173bac4a0
Author: Claus Ibsen <[email protected]>
AuthorDate: Thu Nov 19 09:29:47 2026 +0100

    CAMEL-27229: camel-ftp - ftps checks the server certificate against the JVM 
trust store when no trust store is configured (#30373)
    
    An ftps endpoint configured with neither sslContextParameters nor the
    ftpClient.trustStore options kept the default trust manager of Commons
    Net, which only checks the validity dates of the server certificate.
    It now uses the default trust store of the JVM. The endpoints with
    sslContextParameters, the ftpClient.trustStore options or a custom
    ftpClient are unchanged.
    
    The FTPS integration tests configure a trust store for the certificate
    of the test server. The FTP component page and the 4.24 upgrade guide
    describe how to configure a trust store for a server with a self-signed
    certificate.
    
    Co-Authored-By: Claude Opus 5.5 <[email protected]>
---
 .../apache/camel/catalog/docs/ftp-component.adoc   |  29 ++++--
 .../camel-ftp/src/main/docs/ftp-component.adoc     |  29 ++++--
 .../camel/component/file/remote/FtpsEndpoint.java  |   4 +
 .../file/remote/FtpsEndpointTrustManagerTest.java  | 101 +++++++++++++++++++++
 .../FileToFtpsExplicitSSLWithClientAuthIT.java     |   3 +-
 .../FileToFtpsExplicitSSLWithoutClientAuthIT.java  |   2 +-
 .../FileToFtpsExplicitTLSWithClientAuthIT.java     |   3 +-
 .../FileToFtpsExplicitTLSWithoutClientAuthIT.java  |   2 +-
 .../FileToFtpsImplicitSSLWithClientAuthIT.java     |   3 +-
 .../FileToFtpsImplicitSSLWithoutClientAuthIT.java  |   2 +-
 .../FileToFtpsImplicitTLSWithClientAuthIT.java     |   3 +-
 .../FileToFtpsImplicitTLSWithoutClientAuthIT.java  |   2 +-
 .../FileToFtpsWithDefaultSettingsIPV6IT.java       |   3 +-
 .../FileToFtpsWithDefaultSettingsIT.java           |   3 +-
 .../remote/integration/FtpsServerTestSupport.java  |   6 ++
 .../ROOT/pages/camel-4x-upgrade-guide-4_24.adoc    |  14 +++
 16 files changed, 183 insertions(+), 26 deletions(-)

diff --git 
a/catalog/camel-catalog/src/generated/resources/org/apache/camel/catalog/docs/ftp-component.adoc
 
b/catalog/camel-catalog/src/generated/resources/org/apache/camel/catalog/docs/ftp-component.adoc
index 300a9385a942..ba1219fc9e16 100644
--- 
a/catalog/camel-catalog/src/generated/resources/org/apache/camel/catalog/docs/ftp-component.adoc
+++ 
b/catalog/camel-catalog/src/generated/resources/org/apache/camel/catalog/docs/ftp-component.adoc
@@ -101,14 +101,27 @@ also turns it on or off, and takes precedence over 
`hostnameVerification`, but t
 
 === FTPS component default trust store
 
-When using the `ftpClient.` properties related to SSL with the FTPS
-component, the trust store accepts all certificates. If you only want
-trust selective certificates, you have to configure the trust store with
-the `ftpClient.trustStore.xxx` options or by configuring a custom
-`ftpClient`.
-
-When using `sslContextParameters`, the trust store is managed by the
-configuration of the provided SSLContextParameters instance.
+Without trust settings, an `ftps` endpoint checks the certificate of the 
server against the default trust store of the
+JVM: the `cacerts` file of the JDK, or the trust store set with the 
`javax.net.ssl.trustStore` system property. A server
+certificate signed by a public certificate authority needs no configuration.
+
+For a server with a self-signed certificate, or a certificate signed by your 
own certificate authority, put that
+certificate (or the certificate of the authority) in a trust store and 
configure the endpoint with one of:
+
+* the `ftpClient.trustStore.` options: `ftpClient.trustStore.file`, 
`ftpClient.trustStore.password`, and optionally
+`ftpClient.trustStore.type` (the default key store type of the JVM by default) 
and `ftpClient.trustStore.algorithm`
+(the default trust manager algorithm of the JVM by default).
+* `sslContextParameters`: the trust store is then the one of the provided 
SSLContextParameters instance, and the
+`ftpClient.keyStore.` and `ftpClient.trustStore.` options are not used.
+
+[source,text]
+----
+ftps://admin@myserver/inbox?password=RAW(secret)&ftpClient.trustStore.file=/etc/camel/ftps-truststore.p12&ftpClient.trustStore.type=PKCS12&ftpClient.trustStore.password=RAW(changeit)
+----
+
+A custom `ftpClient` (an `FTPSClient` instance) keeps the trust manager it was 
created with: Camel does not change it.
+To check the server certificate in another way, configure the trust manager 
yourself, on a custom `ftpClient` with
+`setTrustManager`, or with the trust managers of `sslContextParameters`.
 
 You can configure additional options on the `ftpClient` and
 `ftpClientConfig` from the URI directly by using the `ftpClient.` or
diff --git a/components/camel-ftp/src/main/docs/ftp-component.adoc 
b/components/camel-ftp/src/main/docs/ftp-component.adoc
index 300a9385a942..ba1219fc9e16 100644
--- a/components/camel-ftp/src/main/docs/ftp-component.adoc
+++ b/components/camel-ftp/src/main/docs/ftp-component.adoc
@@ -101,14 +101,27 @@ also turns it on or off, and takes precedence over 
`hostnameVerification`, but t
 
 === FTPS component default trust store
 
-When using the `ftpClient.` properties related to SSL with the FTPS
-component, the trust store accepts all certificates. If you only want
-trust selective certificates, you have to configure the trust store with
-the `ftpClient.trustStore.xxx` options or by configuring a custom
-`ftpClient`.
-
-When using `sslContextParameters`, the trust store is managed by the
-configuration of the provided SSLContextParameters instance.
+Without trust settings, an `ftps` endpoint checks the certificate of the 
server against the default trust store of the
+JVM: the `cacerts` file of the JDK, or the trust store set with the 
`javax.net.ssl.trustStore` system property. A server
+certificate signed by a public certificate authority needs no configuration.
+
+For a server with a self-signed certificate, or a certificate signed by your 
own certificate authority, put that
+certificate (or the certificate of the authority) in a trust store and 
configure the endpoint with one of:
+
+* the `ftpClient.trustStore.` options: `ftpClient.trustStore.file`, 
`ftpClient.trustStore.password`, and optionally
+`ftpClient.trustStore.type` (the default key store type of the JVM by default) 
and `ftpClient.trustStore.algorithm`
+(the default trust manager algorithm of the JVM by default).
+* `sslContextParameters`: the trust store is then the one of the provided 
SSLContextParameters instance, and the
+`ftpClient.keyStore.` and `ftpClient.trustStore.` options are not used.
+
+[source,text]
+----
+ftps://admin@myserver/inbox?password=RAW(secret)&ftpClient.trustStore.file=/etc/camel/ftps-truststore.p12&ftpClient.trustStore.type=PKCS12&ftpClient.trustStore.password=RAW(changeit)
+----
+
+A custom `ftpClient` (an `FTPSClient` instance) keeps the trust manager it was 
created with: Camel does not change it.
+To check the server certificate in another way, configure the trust manager 
yourself, on a custom `ftpClient` with
+`setTrustManager`, or with the trust managers of `sslContextParameters`.
 
 You can configure additional options on the `ftpClient` and
 `ftpClientConfig` from the URI directly by using the `ftpClient.` or
diff --git 
a/components/camel-ftp/src/main/java/org/apache/camel/component/file/remote/FtpsEndpoint.java
 
b/components/camel-ftp/src/main/java/org/apache/camel/component/file/remote/FtpsEndpoint.java
index 2790fedfb46c..19af10e7e110 100644
--- 
a/components/camel-ftp/src/main/java/org/apache/camel/component/file/remote/FtpsEndpoint.java
+++ 
b/components/camel-ftp/src/main/java/org/apache/camel/component/file/remote/FtpsEndpoint.java
@@ -42,6 +42,7 @@ import org.apache.commons.net.ftp.FTPClient;
 import org.apache.commons.net.ftp.FTPClientConfig;
 import org.apache.commons.net.ftp.FTPFile;
 import org.apache.commons.net.ftp.FTPSClient;
+import org.apache.commons.net.util.TrustManagerUtils;
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
 
@@ -179,6 +180,9 @@ public class FtpsEndpoint extends FtpEndpoint<FTPFile> {
                 trustMgrFactory.init(trustStore);
 
                 client.setTrustManager(trustMgrFactory.getTrustManagers()[0]);
+            } else {
+                // without trust store options, check the server certificate 
against the JVM default trust store
+                
client.setTrustManager(TrustManagerUtils.getDefaultTrustManager(null));
             }
         }
 
diff --git 
a/components/camel-ftp/src/test/java/org/apache/camel/component/file/remote/FtpsEndpointTrustManagerTest.java
 
b/components/camel-ftp/src/test/java/org/apache/camel/component/file/remote/FtpsEndpointTrustManagerTest.java
new file mode 100644
index 000000000000..289be07995b0
--- /dev/null
+++ 
b/components/camel-ftp/src/test/java/org/apache/camel/component/file/remote/FtpsEndpointTrustManagerTest.java
@@ -0,0 +1,101 @@
+/*
+ * 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.file.remote;
+
+import java.io.InputStream;
+import java.nio.file.Files;
+import java.nio.file.Paths;
+import java.security.KeyStore;
+import java.security.cert.CertificateException;
+import java.security.cert.X509Certificate;
+
+import javax.net.ssl.X509TrustManager;
+
+import org.apache.camel.BindToRegistry;
+import org.apache.camel.test.junit6.CamelTestSupport;
+import org.apache.commons.net.ftp.FTPSClient;
+import org.apache.commons.net.util.TrustManagerUtils;
+import org.junit.jupiter.api.Test;
+
+import static org.junit.jupiter.api.Assertions.assertDoesNotThrow;
+import static org.junit.jupiter.api.Assertions.assertEquals;
+import static org.junit.jupiter.api.Assertions.assertInstanceOf;
+import static org.junit.jupiter.api.Assertions.assertSame;
+import static org.junit.jupiter.api.Assertions.assertThrows;
+
+/**
+ * The trust manager of the FTPS client that the endpoint creates. The 
certificate of the test server is self-signed and
+ * only in src/test/resources/server.jks.
+ */
+public class FtpsEndpointTrustManagerTest extends CamelTestSupport {
+
+    private static final String TRUST_STORE_OPTIONS
+            = 
"ftpClient.trustStore.file=./src/test/resources/server.jks&ftpClient.trustStore.type=JKS"
+              + "&ftpClient.trustStore.password=password";
+
+    @BindToRegistry("customFtpClient")
+    private final FTPSClient customFtpClient = new FTPSClient();
+
+    @Test
+    public void createdClientWithoutTrustSettingsUsesJvmDefaultTrustStore() 
throws Exception {
+        FtpsEndpoint endpoint = context.getEndpoint("ftps://localhost/dir", 
FtpsEndpoint.class);
+
+        FTPSClient client = (FTPSClient) endpoint.createFtpClient();
+
+        
assertEquals(TrustManagerUtils.getDefaultTrustManager(null).getClass(), 
client.getTrustManager().getClass());
+    }
+
+    @Test
+    public void 
createdClientWithoutTrustSettingsRejectsServerCertificateNotInTrustStore() 
throws Exception {
+        FtpsEndpoint endpoint = context.getEndpoint("ftps://localhost/dir", 
FtpsEndpoint.class);
+        X509Certificate[] chain = serverCertificateChain();
+
+        X509TrustManager trustManager
+                = assertInstanceOf(X509TrustManager.class, ((FTPSClient) 
endpoint.createFtpClient()).getTrustManager());
+
+        assertThrows(CertificateException.class, () -> 
trustManager.checkServerTrusted(chain, "RSA"));
+    }
+
+    @Test
+    public void 
createdClientWithTrustStoreOptionsAcceptsServerCertificateInTrustStore() throws 
Exception {
+        FtpsEndpoint endpoint = context.getEndpoint("ftps://localhost/dir?" + 
TRUST_STORE_OPTIONS, FtpsEndpoint.class);
+        X509Certificate[] chain = serverCertificateChain();
+
+        X509TrustManager trustManager
+                = assertInstanceOf(X509TrustManager.class, ((FTPSClient) 
endpoint.createFtpClient()).getTrustManager());
+
+        assertDoesNotThrow(() -> trustManager.checkServerTrusted(chain, 
"RSA"));
+    }
+
+    @Test
+    public void customFtpClientKeepsItsTrustManager() throws Exception {
+        X509TrustManager before = assertInstanceOf(X509TrustManager.class, 
customFtpClient.getTrustManager());
+        FtpsEndpoint endpoint = 
context.getEndpoint("ftps://localhost/dir?ftpClient=#customFtpClient", 
FtpsEndpoint.class);
+
+        endpoint.createRemoteFileOperations();
+
+        assertSame(before, customFtpClient.getTrustManager());
+    }
+
+    private static X509Certificate[] serverCertificateChain() throws Exception 
{
+        KeyStore keyStore = KeyStore.getInstance("JKS");
+        try (InputStream is = 
Files.newInputStream(Paths.get("src/test/resources/server.jks"))) {
+            keyStore.load(is, "password".toCharArray());
+        }
+        return new X509Certificate[] { (X509Certificate) 
keyStore.getCertificate("ftpserver") };
+    }
+}
diff --git 
a/components/camel-ftp/src/test/java/org/apache/camel/component/file/remote/integration/FileToFtpsExplicitSSLWithClientAuthIT.java
 
b/components/camel-ftp/src/test/java/org/apache/camel/component/file/remote/integration/FileToFtpsExplicitSSLWithClientAuthIT.java
index 79693482bbcf..5bd528a06cc2 100644
--- 
a/components/camel-ftp/src/test/java/org/apache/camel/component/file/remote/integration/FileToFtpsExplicitSSLWithClientAuthIT.java
+++ 
b/components/camel-ftp/src/test/java/org/apache/camel/component/file/remote/integration/FileToFtpsExplicitSSLWithClientAuthIT.java
@@ -31,7 +31,8 @@ public class FileToFtpsExplicitSSLWithClientAuthIT extends 
FtpsServerExplicitSSL
         return "ftps://admin@localhost:{{ftp.server.port}}"
                + 
"/tmp2/camel?password=admin&initialDelay=2000&disableSecureDataChannelDefaults=true"
                + 
"&securityProtocol=TLSv1.2&implicit=false&ftpClient.keyStore.file=./src/test/resources/server.jks&ftpClient.keyStore.type=JKS"
-               + 
"&ftpClient.keyStore.algorithm=SunX509&ftpClient.keyStore.password=password&ftpClient.keyStore.keyPassword=password&delete=true";
+               + 
"&ftpClient.keyStore.algorithm=SunX509&ftpClient.keyStore.password=password&ftpClient.keyStore.keyPassword=password&delete=true"
+               + TRUST_STORE_OPTIONS;
     }
 
     @Test
diff --git 
a/components/camel-ftp/src/test/java/org/apache/camel/component/file/remote/integration/FileToFtpsExplicitSSLWithoutClientAuthIT.java
 
b/components/camel-ftp/src/test/java/org/apache/camel/component/file/remote/integration/FileToFtpsExplicitSSLWithoutClientAuthIT.java
index 688ab1f71caa..0e48b3b221cb 100644
--- 
a/components/camel-ftp/src/test/java/org/apache/camel/component/file/remote/integration/FileToFtpsExplicitSSLWithoutClientAuthIT.java
+++ 
b/components/camel-ftp/src/test/java/org/apache/camel/component/file/remote/integration/FileToFtpsExplicitSSLWithoutClientAuthIT.java
@@ -30,7 +30,7 @@ public class FileToFtpsExplicitSSLWithoutClientAuthIT extends 
FtpsServerExplicit
     protected String getFtpUrl() {
         return "ftps://admin@localhost:" + service.getPort()
                + 
"/tmp2/camel?password=admin&initialDelay=2000&disableSecureDataChannelDefaults=true&delete=true"
-               + "&securityProtocol=TLSv1.2&implicit=false";
+               + "&securityProtocol=TLSv1.2&implicit=false" + 
TRUST_STORE_OPTIONS;
     }
 
     @Test
diff --git 
a/components/camel-ftp/src/test/java/org/apache/camel/component/file/remote/integration/FileToFtpsExplicitTLSWithClientAuthIT.java
 
b/components/camel-ftp/src/test/java/org/apache/camel/component/file/remote/integration/FileToFtpsExplicitTLSWithClientAuthIT.java
index b31be68340fe..e5202a54bbb0 100644
--- 
a/components/camel-ftp/src/test/java/org/apache/camel/component/file/remote/integration/FileToFtpsExplicitTLSWithClientAuthIT.java
+++ 
b/components/camel-ftp/src/test/java/org/apache/camel/component/file/remote/integration/FileToFtpsExplicitTLSWithClientAuthIT.java
@@ -32,7 +32,8 @@ public class FileToFtpsExplicitTLSWithClientAuthIT extends 
FtpsServerExplicitTLS
         return "ftps://admin@localhost:{{ftp.server.port}}"
                + 
"/tmp2/camel?password=admin&initialDelay=2000&disableSecureDataChannelDefaults=true"
                + 
"&securityProtocol=TLSv1.3&implicit=false&ftpClient.keyStore.file=./src/test/resources/server.jks&ftpClient.keyStore.type=JKS"
-               + 
"&ftpClient.keyStore.algorithm=SunX509&ftpClient.keyStore.password=password&ftpClient.keyStore.keyPassword=password&delete=true";
+               + 
"&ftpClient.keyStore.algorithm=SunX509&ftpClient.keyStore.password=password&ftpClient.keyStore.keyPassword=password&delete=true"
+               + TRUST_STORE_OPTIONS;
     }
 
     @Disabled("Embedded Apache FtpServer does not support TLS 1.3")
diff --git 
a/components/camel-ftp/src/test/java/org/apache/camel/component/file/remote/integration/FileToFtpsExplicitTLSWithoutClientAuthIT.java
 
b/components/camel-ftp/src/test/java/org/apache/camel/component/file/remote/integration/FileToFtpsExplicitTLSWithoutClientAuthIT.java
index 06e1db5fd593..7ec628337a27 100644
--- 
a/components/camel-ftp/src/test/java/org/apache/camel/component/file/remote/integration/FileToFtpsExplicitTLSWithoutClientAuthIT.java
+++ 
b/components/camel-ftp/src/test/java/org/apache/camel/component/file/remote/integration/FileToFtpsExplicitTLSWithoutClientAuthIT.java
@@ -31,7 +31,7 @@ public class FileToFtpsExplicitTLSWithoutClientAuthIT extends 
FtpsServerExplicit
     protected String getFtpUrl() {
         return "ftps://admin@localhost:{{ftp.server.port}}"
                + 
"/tmp2/camel?password=admin&initialDelay=2000&disableSecureDataChannelDefaults=true"
-               + "&securityProtocol=TLSv1.3&implicit=false&delete=true";
+               + "&securityProtocol=TLSv1.3&implicit=false&delete=true" + 
TRUST_STORE_OPTIONS;
     }
 
     @Disabled("Embedded Apache FtpServer does not support TLS 1.3")
diff --git 
a/components/camel-ftp/src/test/java/org/apache/camel/component/file/remote/integration/FileToFtpsImplicitSSLWithClientAuthIT.java
 
b/components/camel-ftp/src/test/java/org/apache/camel/component/file/remote/integration/FileToFtpsImplicitSSLWithClientAuthIT.java
index 95d354883201..15b85ade8e9d 100644
--- 
a/components/camel-ftp/src/test/java/org/apache/camel/component/file/remote/integration/FileToFtpsImplicitSSLWithClientAuthIT.java
+++ 
b/components/camel-ftp/src/test/java/org/apache/camel/component/file/remote/integration/FileToFtpsImplicitSSLWithClientAuthIT.java
@@ -31,7 +31,8 @@ public class FileToFtpsImplicitSSLWithClientAuthIT extends 
FtpsServerImplicitSSL
         return "ftps://admin@localhost:" + service.getPort()
                + 
"/tmp2/camel?password=admin&initialDelay=2000&disableSecureDataChannelDefaults=true"
                + 
"&securityProtocol=TLSv1.2&implicit=true&ftpClient.keyStore.file=./src/test/resources/server.jks&ftpClient.keyStore.type=JKS"
-               + 
"&ftpClient.keyStore.algorithm=SunX509&ftpClient.keyStore.password=password&ftpClient.keyStore.keyPassword=password&delete=true";
+               + 
"&ftpClient.keyStore.algorithm=SunX509&ftpClient.keyStore.password=password&ftpClient.keyStore.keyPassword=password&delete=true"
+               + TRUST_STORE_OPTIONS;
     }
 
     @Test
diff --git 
a/components/camel-ftp/src/test/java/org/apache/camel/component/file/remote/integration/FileToFtpsImplicitSSLWithoutClientAuthIT.java
 
b/components/camel-ftp/src/test/java/org/apache/camel/component/file/remote/integration/FileToFtpsImplicitSSLWithoutClientAuthIT.java
index 52a731442bf5..82d3e19f2e17 100644
--- 
a/components/camel-ftp/src/test/java/org/apache/camel/component/file/remote/integration/FileToFtpsImplicitSSLWithoutClientAuthIT.java
+++ 
b/components/camel-ftp/src/test/java/org/apache/camel/component/file/remote/integration/FileToFtpsImplicitSSLWithoutClientAuthIT.java
@@ -30,7 +30,7 @@ public class FileToFtpsImplicitSSLWithoutClientAuthIT extends 
FtpsServerImplicit
     protected String getFtpUrl() {
         return "ftps://admin@localhost:{{ftp.server.port}}"
                + 
"/tmp2/camel?password=admin&initialDelay=2000&disableSecureDataChannelDefaults=true"
-               + "&securityProtocol=TLSv1.2&implicit=true&delete=true";
+               + "&securityProtocol=TLSv1.2&implicit=true&delete=true" + 
TRUST_STORE_OPTIONS;
     }
 
     @Test
diff --git 
a/components/camel-ftp/src/test/java/org/apache/camel/component/file/remote/integration/FileToFtpsImplicitTLSWithClientAuthIT.java
 
b/components/camel-ftp/src/test/java/org/apache/camel/component/file/remote/integration/FileToFtpsImplicitTLSWithClientAuthIT.java
index d2668205cfcc..65fce311d61a 100644
--- 
a/components/camel-ftp/src/test/java/org/apache/camel/component/file/remote/integration/FileToFtpsImplicitTLSWithClientAuthIT.java
+++ 
b/components/camel-ftp/src/test/java/org/apache/camel/component/file/remote/integration/FileToFtpsImplicitTLSWithClientAuthIT.java
@@ -32,7 +32,8 @@ public class FileToFtpsImplicitTLSWithClientAuthIT extends 
FtpsServerImplicitTLS
         return "ftps://admin@localhost:{{ftp.server.port}}"
                + 
"/tmp2/camel?password=admin&initialDelay=2000&disableSecureDataChannelDefaults=true"
                + 
"&securityProtocol=TLSv1.3&implicit=true&ftpClient.keyStore.file=./src/test/resources/server.jks&ftpClient.keyStore.type=JKS"
-               + 
"&ftpClient.keyStore.algorithm=SunX509&ftpClient.keyStore.password=password&ftpClient.keyStore.keyPassword=password&delete=true";
+               + 
"&ftpClient.keyStore.algorithm=SunX509&ftpClient.keyStore.password=password&ftpClient.keyStore.keyPassword=password&delete=true"
+               + TRUST_STORE_OPTIONS;
     }
 
     @Disabled("Embedded Apache FtpServer does not support TLS 1.3")
diff --git 
a/components/camel-ftp/src/test/java/org/apache/camel/component/file/remote/integration/FileToFtpsImplicitTLSWithoutClientAuthIT.java
 
b/components/camel-ftp/src/test/java/org/apache/camel/component/file/remote/integration/FileToFtpsImplicitTLSWithoutClientAuthIT.java
index 8294ff1e00ec..65ede4b20a68 100644
--- 
a/components/camel-ftp/src/test/java/org/apache/camel/component/file/remote/integration/FileToFtpsImplicitTLSWithoutClientAuthIT.java
+++ 
b/components/camel-ftp/src/test/java/org/apache/camel/component/file/remote/integration/FileToFtpsImplicitTLSWithoutClientAuthIT.java
@@ -31,7 +31,7 @@ public class FileToFtpsImplicitTLSWithoutClientAuthIT extends 
FtpsServerImplicit
     protected String getFtpUrl() {
         return "ftps://admin@localhost:{{ftp.server.port}}"
                + 
"/tmp2/camel?password=admin&initialDelay=2000&disableSecureDataChannelDefaults=true"
-               + "&securityProtocol=TLSv1.3&implicit=true&delete=true";
+               + "&securityProtocol=TLSv1.3&implicit=true&delete=true" + 
TRUST_STORE_OPTIONS;
     }
 
     @Disabled("Embedded Apache FtpServer does not support TLS 1.3")
diff --git 
a/components/camel-ftp/src/test/java/org/apache/camel/component/file/remote/integration/FileToFtpsWithDefaultSettingsIPV6IT.java
 
b/components/camel-ftp/src/test/java/org/apache/camel/component/file/remote/integration/FileToFtpsWithDefaultSettingsIPV6IT.java
index 5cee515a1c6f..19c367f752aa 100644
--- 
a/components/camel-ftp/src/test/java/org/apache/camel/component/file/remote/integration/FileToFtpsWithDefaultSettingsIPV6IT.java
+++ 
b/components/camel-ftp/src/test/java/org/apache/camel/component/file/remote/integration/FileToFtpsWithDefaultSettingsIPV6IT.java
@@ -29,7 +29,8 @@ public class FileToFtpsWithDefaultSettingsIPV6IT extends 
FtpsServerExplicitTLSWi
 
     private String getFtpUrl() {
         return "ftps://admin@[::1]:{{ftp.server.port}}"
-               + 
"/tmp2/camel?password=admin&initialDelay=2000&disableSecureDataChannelDefaults=true&delete=true";
+               + 
"/tmp2/camel?password=admin&initialDelay=2000&disableSecureDataChannelDefaults=true&delete=true"
+               + TRUST_STORE_OPTIONS;
     }
 
     @Test
diff --git 
a/components/camel-ftp/src/test/java/org/apache/camel/component/file/remote/integration/FileToFtpsWithDefaultSettingsIT.java
 
b/components/camel-ftp/src/test/java/org/apache/camel/component/file/remote/integration/FileToFtpsWithDefaultSettingsIT.java
index 29edc6b1109b..9a700b8e9083 100644
--- 
a/components/camel-ftp/src/test/java/org/apache/camel/component/file/remote/integration/FileToFtpsWithDefaultSettingsIT.java
+++ 
b/components/camel-ftp/src/test/java/org/apache/camel/component/file/remote/integration/FileToFtpsWithDefaultSettingsIT.java
@@ -30,7 +30,8 @@ public class FileToFtpsWithDefaultSettingsIT extends 
FtpsServerExplicitTLSWithou
 
     private String getFtpUrl() {
         return "ftps://admin@localhost:{{ftp.server.port}}"
-               + 
"/tmp2/camel?password=admin&initialDelay=2000&disableSecureDataChannelDefaults=true&delete=true";
+               + 
"/tmp2/camel?password=admin&initialDelay=2000&disableSecureDataChannelDefaults=true&delete=true"
+               + TRUST_STORE_OPTIONS;
     }
 
     @Disabled("Embedded Apache FtpServer does not support TLS 1.3")
diff --git 
a/components/camel-ftp/src/test/java/org/apache/camel/component/file/remote/integration/FtpsServerTestSupport.java
 
b/components/camel-ftp/src/test/java/org/apache/camel/component/file/remote/integration/FtpsServerTestSupport.java
index 36956e278d55..cec83fafe929 100644
--- 
a/components/camel-ftp/src/test/java/org/apache/camel/component/file/remote/integration/FtpsServerTestSupport.java
+++ 
b/components/camel-ftp/src/test/java/org/apache/camel/component/file/remote/integration/FtpsServerTestSupport.java
@@ -24,4 +24,10 @@ import 
org.apache.camel.component.file.remote.BaseServerTestSupport;
 public abstract class FtpsServerTestSupport extends BaseServerTestSupport {
     protected static final String AUTH_VALUE_SSL = "TLSv1.2";
     protected static final String AUTH_VALUE_TLS = "TLSv1.3";
+
+    /**
+     * Endpoint options for a trust store with the certificate of the test 
server, which is self-signed.
+     */
+    protected static final String TRUST_STORE_OPTIONS = 
"&ftpClient.trustStore.file=./src/test/resources/server.jks"
+                                                        + 
"&ftpClient.trustStore.type=JKS&ftpClient.trustStore.password=password";
 }
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 99a5e57a5fc7..4dbf2897885b 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
@@ -667,6 +667,20 @@ Before, JSch skipped a name such as `Password`, as it 
compares the names with th
 login failed with `Auth fail for methods '...'`. A name that JSch does not 
know is logged at WARN when the endpoint
 starts. See the xref:components::sftp-component.adoc[SFTP component].
 
+=== camel-ftp - ftps checks the server certificate against the JVM trust store 
when no trust store is configured
+
+An `ftps` endpoint configured with neither `sslContextParameters` nor the 
`ftpClient.trustStore.` options now checks the
+certificate of the server against the default trust store of the JVM (the 
`cacerts` file of the JDK, or the trust
+store set with the `javax.net.ssl.trustStore` system property). Before, such 
an endpoint accepted any server
+certificate within its validity dates, without checking who signed it.
+
+A server certificate signed by a public certificate authority works as before. 
For an FTPS server with a self-signed
+certificate, or a certificate signed by your own certificate authority, the 
connection now fails in the TLS handshake:
+put that certificate (or the certificate of the authority) in a trust store, 
and configure it with the
+`ftpClient.trustStore.file`, `ftpClient.trustStore.password` and 
`ftpClient.trustStore.type` options, or with
+`sslContextParameters`. A custom `ftpClient` keeps the trust manager it was 
created with. See
+xref:components::ftp-component.adoc#_ftps_component_default_trust_store[FTPS 
component default trust store].
+
 === camel-smb - a starting directory that cannot be created
 
 When the server refuses to create the starting directory of the `smb` consumer 
as the route starts (`autoCreate=true`),

Reply via email to