This is an automated email from the ASF dual-hosted git repository.
davsclaus pushed a commit to branch camel-4.18.x
in repository https://gitbox.apache.org/repos/asf/camel.git
The following commit(s) were added to refs/heads/camel-4.18.x by this push:
new 681d70e5b687 [backport camel-4.18.x] CAMEL-27228: camel-vertx-http -
an https:// address is called with TLS also when no sslContextParameters is
configured (#30382)
681d70e5b687 is described below
commit 681d70e5b68719003a0585647390dac0e1b81b88
Author: Claus Ibsen <[email protected]>
AuthorDate: Thu Nov 19 13:29:34 2026 +0100
[backport camel-4.18.x] CAMEL-27228: camel-vertx-http - an https:// address
is called with TLS also when no sslContextParameters is configured (#30382)
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]>
(cherry picked from commit ec14c4a9edaac36c4e588418c553795988c7963d,
adapted for camel-4.18.x)
---
.../src/main/docs/vertx-http-component.adoc | 3 +
.../vertx/http/DefaultVertxHttpBinding.java | 5 ++
.../vertx/http/VertxHttpHttpsAddressTlsTest.java | 99 ++++++++++++++++++++++
3 files changed, 107 insertions(+)
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 a3e3200b848f..4064cd054245 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
@@ -141,6 +141,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 8b76a47888ca..572f59ae4205 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
@@ -87,6 +87,11 @@ public class DefaultVertxHttpBinding implements
VertxHttpBinding {
} else {
request = webClient.requestAbs(method, uri.toString());
}
+ // 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 query params
if (ObjectHelper.isNotEmpty(queryString)) {
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..5073704367f7
--- /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.junit5.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);
+ }
+}