oscerd commented on code in PR #28305:
URL: https://github.com/apache/camel/pull/28305#discussion_r4357154762


##########
components/camel-vertx/camel-vertx-common/src/test/java/org/apache/camel/component/vertx/common/VertxHelperTest.java:
##########
@@ -0,0 +1,128 @@
+/*
+ * 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.security.cert.CertificateException;
+import java.security.cert.X509Certificate;
+
+import javax.net.ssl.X509TrustManager;
+
+import io.vertx.core.net.NetClientOptions;
+import io.vertx.core.net.TCPSSLOptions;
+import org.apache.camel.CamelContext;
+import org.apache.camel.impl.DefaultCamelContext;
+import org.apache.camel.support.jsse.KeyStoreParameters;
+import org.apache.camel.support.jsse.SSLContextParameters;
+import org.apache.camel.support.jsse.TrustAllTrustManager;
+import org.apache.camel.support.jsse.TrustManagersParameters;
+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;
+
+public class VertxHelperTest {
+
+    private CamelContext context;
+
+    @BeforeEach
+    public void setUp() {
+        context = new DefaultCamelContext();
+    }
+
+    @AfterEach
+    public void tearDown() throws Exception {
+        if (context != null) {
+            context.stop();
+        }
+    }
+
+    @Test
+    public void testStandaloneCustomTrustManagerApplied() throws Exception {
+        SSLContextParameters sslContextParameters = new SSLContextParameters();
+        TrustManagersParameters trustManagers = new TrustManagersParameters();
+
+        X509TrustManager customTrustManager = new X509TrustManager() {
+            @Override
+            public void checkClientTrusted(X509Certificate[] chain, String 
authType) throws CertificateException {
+                throw new CertificateException("Custom reject");
+            }
+
+            @Override
+            public void checkServerTrusted(X509Certificate[] chain, String 
authType) throws CertificateException {
+                throw new CertificateException("Custom reject");
+            }
+
+            @Override
+            public X509Certificate[] getAcceptedIssuers() {
+                return new X509Certificate[0];
+            }
+        };
+
+        trustManagers.setTrustManager(customTrustManager);
+        sslContextParameters.setTrustManagers(trustManagers);
+
+        TCPSSLOptions options = new NetClientOptions();
+        VertxHelper.setupSSLOptions(context, sslContextParameters, options);
+
+        assertThat(options.isSsl()).isTrue();
+        assertThat(options.getTrustOptions()).isNotNull();

Review Comment:
   Done in the commit "CAMEL-25964: Address review feedback - assert the 
TrustManager that Vert.x applies, and document the TrustManager-over-keystore 
case": the test now asserts 
`getTrustOptions().getTrustManagerFactory(null).getTrustManagers()` contains 
exactly the custom manager, as suggested.
   
   _Claude Code on behalf of oscerd_
   



##########
components/camel-vertx/camel-vertx-common/src/test/java/org/apache/camel/component/vertx/common/VertxHelperTest.java:
##########
@@ -0,0 +1,128 @@
+/*
+ * 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.security.cert.CertificateException;
+import java.security.cert.X509Certificate;
+
+import javax.net.ssl.X509TrustManager;
+
+import io.vertx.core.net.NetClientOptions;
+import io.vertx.core.net.TCPSSLOptions;
+import org.apache.camel.CamelContext;
+import org.apache.camel.impl.DefaultCamelContext;
+import org.apache.camel.support.jsse.KeyStoreParameters;
+import org.apache.camel.support.jsse.SSLContextParameters;
+import org.apache.camel.support.jsse.TrustAllTrustManager;
+import org.apache.camel.support.jsse.TrustManagersParameters;
+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;
+
+public class VertxHelperTest {
+
+    private CamelContext context;
+
+    @BeforeEach
+    public void setUp() {
+        context = new DefaultCamelContext();
+    }
+
+    @AfterEach
+    public void tearDown() throws Exception {
+        if (context != null) {
+            context.stop();
+        }
+    }
+
+    @Test
+    public void testStandaloneCustomTrustManagerApplied() throws Exception {
+        SSLContextParameters sslContextParameters = new SSLContextParameters();
+        TrustManagersParameters trustManagers = new TrustManagersParameters();
+
+        X509TrustManager customTrustManager = new X509TrustManager() {
+            @Override
+            public void checkClientTrusted(X509Certificate[] chain, String 
authType) throws CertificateException {
+                throw new CertificateException("Custom reject");
+            }
+
+            @Override
+            public void checkServerTrusted(X509Certificate[] chain, String 
authType) throws CertificateException {
+                throw new CertificateException("Custom reject");
+            }
+
+            @Override
+            public X509Certificate[] getAcceptedIssuers() {
+                return new X509Certificate[0];
+            }
+        };
+
+        trustManagers.setTrustManager(customTrustManager);
+        sslContextParameters.setTrustManagers(trustManagers);
+
+        TCPSSLOptions options = new NetClientOptions();
+        VertxHelper.setupSSLOptions(context, sslContextParameters, options);
+
+        assertThat(options.isSsl()).isTrue();
+        assertThat(options.getTrustOptions()).isNotNull();
+    }
+
+    @Test
+    public void testTrustAllTrustManagerApplied() throws Exception {
+        SSLContextParameters sslContextParameters = new SSLContextParameters();
+        TrustManagersParameters trustManagers = new TrustManagersParameters();
+        trustManagers.setTrustManager(TrustAllTrustManager.INSTANCE);
+        sslContextParameters.setTrustManagers(trustManagers);
+
+        TCPSSLOptions options = new NetClientOptions();
+        VertxHelper.setupSSLOptions(context, sslContextParameters, options);
+
+        assertThat(options.isSsl()).isTrue();
+        assertThat(options.getTrustOptions()).isNotNull();

Review Comment:
   Done in the same commit: the trust-all test now asserts the factory holds 
exactly `TrustAllTrustManager.INSTANCE`.
   
   _Claude Code on behalf of oscerd_
   



##########
docs/user-manual/modules/ROOT/pages/camel-4x-upgrade-guide-4_24.adoc:
##########
@@ -1464,6 +1464,10 @@ Every other value is converted to one String and sent as 
one header as before: a
 commas), a `byte[]` and the other primitive arrays, a `Map`, and a Vert.x 
`JsonObject` or `JsonArray` (sent as JSON).
 A route that needs the old single header can set the header to a String, for 
example with `String.valueOf(list)`.
 
+=== camel-vertx - standalone TrustManager on SSLContextParameters is applied
+
+When configuring TLS through `SSLContextParameters` with a standalone 
`TrustManager` instance (via `TrustManagersParameters.setTrustManager(...)`), 
Vert.x components now wrap and apply the configured `TrustManager`. Previously, 
only `TrustAllTrustManager.INSTANCE` and KeyStore-backed configurations were 
applied, and other standalone `TrustManager` instances were not set on the 
underlying Vert.x options.

Review Comment:
   Added as a second paragraph of the note: when both a `TrustManager` and a 
keystore are configured on `TrustManagersParameters`, the `TrustManager` is now 
used, as with the other components that use `SSLContextParameters`; before, the 
keystore-based trust options were used.
   
   _Claude Code on behalf of oscerd_
   



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]

Reply via email to