This is an automated email from the ASF dual-hosted git repository.
davsclaus pushed a commit to branch camel-4.22.x
in repository https://gitbox.apache.org/repos/asf/camel.git
The following commit(s) were added to refs/heads/camel-4.22.x by this push:
new a41a575cbdb0 [backport camel-4.22.x] CAMEL-27228: camel-vertx-http -
an https:// address is called with TLS also when no sslContextParameters is
configured (#30380)
a41a575cbdb0 is described below
commit a41a575cbdb00edd45d91e9d6a8559a343841dbc
Author: Claus Ibsen <[email protected]>
AuthorDate: Thu Nov 19 10:10:09 2026 +0100
[backport camel-4.22.x] CAMEL-27228: camel-vertx-http - an https:// address
is called with TLS also when no sslContextParameters is configured (#30380)
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)
---
.../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 ++++++++++++++++++++++
4 files changed, 110 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 87f57ffb4064..259137b08052 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
@@ -195,6 +195,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 87f57ffb4064..259137b08052 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
@@ -195,6 +195,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 d16cb2a0dbfe..51fd6c719621 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
@@ -92,6 +92,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);
+ }
+}