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 ec14c4a9edaa CAMEL-27228: camel-vertx-http - an https:// address is 
called with TLS also when no sslContextParameters is configured (#30372)
ec14c4a9edaa is described below

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

    CAMEL-27228: camel-vertx-http - an https:// address is called with TLS also 
when no sslContextParameters is configured (#30372)
    
    In direct mode (no proxy) the request is built with 
WebClient.request(method, port, host, path), which does not
    take TLS from the scheme. TLS was then only used when the WebClientOptions 
turned it on, that is with
    sslContextParameters. The request now turns on TLS when the address is 
https://.
    
    Co-Authored-By: Claude Opus 5.5 <[email protected]>
---
 .../camel/catalog/docs/vertx-http-component.adoc   |  3 +
 .../src/main/docs/vertx-http-component.adoc        |  3 +
 .../vertx/http/DefaultVertxHttpBinding.java        |  5 ++
 .../vertx/http/VertxHttpHttpsAddressTlsTest.java   | 99 ++++++++++++++++++++++
 .../ROOT/pages/camel-4x-upgrade-guide-4_24.adoc    | 11 +++
 5 files changed, 121 insertions(+)

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 802d3ee848e4..39655215ce68 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
@@ -214,6 +214,9 @@ The Vert.x HTTP component supports SSL/TLS configuration 
through the xref:manual
 
 It is also possible to configure SSL options by providing a custom 
`WebClientOptions`.
 
+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.
+
 === 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-http/src/main/docs/vertx-http-component.adoc
 
b/components/camel-vertx/camel-vertx-http/src/main/docs/vertx-http-component.adoc
index 802d3ee848e4..39655215ce68 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
@@ -214,6 +214,9 @@ The Vert.x HTTP component supports SSL/TLS configuration 
through the xref:manual
 
 It is also possible to configure SSL options by providing a custom 
`WebClientOptions`.
 
+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.
+
 === 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-http/src/main/java/org/apache/camel/component/vertx/http/DefaultVertxHttpBinding.java
 
b/components/camel-vertx/camel-vertx-http/src/main/java/org/apache/camel/component/vertx/http/DefaultVertxHttpBinding.java
index bfea3e1506de..ed8326f0d5c3 100644
--- 
a/components/camel-vertx/camel-vertx-http/src/main/java/org/apache/camel/component/vertx/http/DefaultVertxHttpBinding.java
+++ 
b/components/camel-vertx/camel-vertx-http/src/main/java/org/apache/camel/component/vertx/http/DefaultVertxHttpBinding.java
@@ -96,6 +96,11 @@ public class DefaultVertxHttpBinding implements 
VertxHttpBinding {
                 int port = "https".equals(uri.getScheme()) ? 443 : 80;
                 request = webClient.request(method, port, uri.getHost(), 
pathAndQuery);
             }
+            // request() does not take TLS from the scheme, as requestAbs() 
does, so an https address
+            // turns on TLS for this request also when the WebClientOptions do 
not (no sslContextParameters)
+            if ("https".equalsIgnoreCase(uri.getScheme())) {
+                request.ssl(Boolean.TRUE);
+            }
         }
 
         // Configure basic authentication
diff --git 
a/components/camel-vertx/camel-vertx-http/src/test/java/org/apache/camel/component/vertx/http/VertxHttpHttpsAddressTlsTest.java
 
b/components/camel-vertx/camel-vertx-http/src/test/java/org/apache/camel/component/vertx/http/VertxHttpHttpsAddressTlsTest.java
new file mode 100644
index 000000000000..2e89d58f33ce
--- /dev/null
+++ 
b/components/camel-vertx/camel-vertx-http/src/test/java/org/apache/camel/component/vertx/http/VertxHttpHttpsAddressTlsTest.java
@@ -0,0 +1,99 @@
+/*
+ * 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.http;
+
+import java.io.InputStream;
+import java.net.InetAddress;
+import java.net.ServerSocket;
+import java.net.Socket;
+import java.util.concurrent.CompletableFuture;
+import java.util.concurrent.TimeUnit;
+
+import io.vertx.core.buffer.Buffer;
+import io.vertx.ext.web.client.HttpRequest;
+import org.apache.camel.Exchange;
+import org.apache.camel.support.DefaultExchange;
+import org.apache.camel.test.junit6.CamelTestSupport;
+import org.junit.jupiter.api.Test;
+
+import static org.junit.jupiter.api.Assertions.assertEquals;
+import static org.junit.jupiter.api.Assertions.assertNotEquals;
+import static org.junit.jupiter.api.Assertions.assertTrue;
+
+/**
+ * An https:// address is called with TLS also when no sslContextParameters is 
configured on the endpoint.
+ */
+public class VertxHttpHttpsAddressTlsTest extends CamelTestSupport {
+
+    // the first byte of a TLS record that carries a handshake message (the 
ClientHello)
+    private static final int TLS_HANDSHAKE = 0x16;
+
+    @Test
+    public void testHttpsAddressWithPortUsesTls() throws Exception {
+        assertEquals(Boolean.TRUE, 
prepareRequest("vertx-http:https://localhost:8443/api";).ssl());
+    }
+
+    @Test
+    public void testHttpsAddressWithoutPortUsesTls() throws Exception {
+        HttpRequest<Buffer> request = 
prepareRequest("vertx-http:https://localhost/api";);
+        assertEquals(Boolean.TRUE, request.ssl());
+        assertEquals(443, request.port());
+    }
+
+    @Test
+    public void testHttpsAddressWithProxyUsesTls() throws Exception {
+        assertEquals(Boolean.TRUE,
+                
prepareRequest("vertx-http:https://localhost:8443/api?proxyHost=localhost&proxyPort=3128";).ssl());
+    }
+
+    @Test
+    public void testHttpAddressDoesNotSetTls() throws Exception {
+        assertNotEquals(Boolean.TRUE, 
prepareRequest("vertx-http:http://localhost:8080/api";).ssl());
+        assertNotEquals(Boolean.TRUE, 
prepareRequest("vertx-http:http://localhost/api";).ssl());
+    }
+
+    @Test
+    public void testHttpsAddressStartsWithTlsHandshake() throws Exception {
+        try (ServerSocket server = new ServerSocket(0, 1, 
InetAddress.getLoopbackAddress())) {
+            CompletableFuture<Integer> firstByte = 
CompletableFuture.supplyAsync(() -> {
+                try (Socket socket = server.accept(); InputStream in = 
socket.getInputStream()) {
+                    return in.read();
+                } catch (Exception e) {
+                    throw new RuntimeException(e);
+                }
+            });
+
+            CompletableFuture<Exchange> reply = template.asyncSend(
+                    "vertx-http:https://localhost:"; + server.getLocalPort() + 
"/api?httpMethod=POST",
+                    e -> e.getMessage().setBody("Hello World"));
+
+            int b = firstByte.get(10, TimeUnit.SECONDS);
+            assertEquals(TLS_HANDSHAKE, b, "the client must start with a TLS 
handshake, not an HTTP request line");
+
+            // the server closed the connection without a TLS answer, so the 
call fails
+            Exchange out = reply.get(20, TimeUnit.SECONDS);
+            assertTrue(out.isFailed());
+        }
+    }
+
+    private HttpRequest<Buffer> prepareRequest(String uri) throws Exception {
+        VertxHttpEndpoint endpoint = context.getEndpoint(uri, 
VertxHttpEndpoint.class);
+        endpoint.start();
+        Exchange exchange = new DefaultExchange(context);
+        return new DefaultVertxHttpBinding().prepareHttpRequest(endpoint, 
exchange);
+    }
+}
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 f438d3c439c0..99a5e57a5fc7 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
@@ -253,6 +253,17 @@ Before, its lock failed with an `OptimisticLockException`, 
and the poll was roll
 
 Other JPA providers, and the optimistic lock modes, are not affected.
 
+=== camel-vertx-http - an https:// address always uses TLS
+
+A `vertx-http` endpoint with an `https://` address now always calls it with 
TLS, also when no `sslContextParameters`
+is configured. The server certificate is then checked with the default trust 
store of the JVM, and the host name is
+verified. Before, the request was sent without TLS unless TLS was turned on by 
`sslContextParameters`, global SSL
+settings or custom `WebClientOptions`. This applied to `https://` addresses 
with an explicit port, and since 4.21 to
+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-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

Reply via email to