From 38bad3c6c13d524c0a0a4b374716c3b032cbafa1 Mon Sep 17 00:00:00 2001 From: Claus Ibsen Date: Mon, 7 Sep 2026 20:50:34 +0200 Subject: [PATCH 1/2] [backport camel-4.18.x] CAMEL-24632: camel-http - fix proxy scheme defaulting to https for https targets (#26171) * CAMEL-24632: camel-http - fix proxy scheme defaulting to https for https targets HttpComponent.configureHttpProxy() was deriving the proxy connection scheme from the target endpoint scheme (secure ? "https" : "http"), which is wrong. The proxy connection scheme is independent of the target: connecting to an HTTPS target through an HTTP proxy uses a plain HTTP CONNECT tunnel, with TLS established end-to-end inside that tunnel. Fix defaults proxyAuthScheme to "http" unconditionally in HttpComponent, HttpEndpoint (deprecated global-options path), and updates the defaultValue metadata in HttpCommonEndpoint and HttpConfiguration. The unused boolean secure parameter is also removed from configureHttpProxy(). Catalog and DSL regenerated. Closes #26167 Co-Authored-By: Claude Sonnet 4.6 * CAMEL-24632: fix malformed JSON in backport-merged generated files Co-Authored-By: Claude Sonnet 4.6 Signed-off-by: Claus Ibsen --------- Signed-off-by: Claus Ibsen Co-authored-by: Claude Sonnet 4.6 --- .../camel/http/common/HttpCommonEndpoint.java | 4 ++- .../camel/http/common/HttpConfiguration.java | 4 ++- .../camel/component/http/HttpComponent.java | 23 ++++++++++----- .../camel/component/http/HttpEndpoint.java | 5 ++-- .../component/http/HttpProxyServerTest.java | 28 +++++++++++++++++++ 5 files changed, 52 insertions(+), 12 deletions(-) diff --git a/components/camel-http-common/src/main/java/org/apache/camel/http/common/HttpCommonEndpoint.java b/components/camel-http-common/src/main/java/org/apache/camel/http/common/HttpCommonEndpoint.java index 7ad028318c3b5..6f65939abc366 100644 --- a/components/camel-http-common/src/main/java/org/apache/camel/http/common/HttpCommonEndpoint.java +++ b/components/camel-http-common/src/main/java/org/apache/camel/http/common/HttpCommonEndpoint.java @@ -170,7 +170,9 @@ public abstract class HttpCommonEndpoint extends DefaultEndpoint private String proxyHost; @UriParam(label = "producer,proxy", description = "Proxy port to use") private int proxyPort; - @UriParam(label = "producer,proxy", enums = "http,https", description = "Proxy authentication scheme to use") + @UriParam(label = "producer,proxy", enums = "http,https", defaultValue = "http", + description = "Proxy server connection protocol scheme. Defaults to http regardless of the target endpoint scheme," + + " because most corporate HTTP proxies expect a plain HTTP connection on their listener port.") private String proxyAuthScheme; @UriParam(label = "producer,proxy", enums = "Basic,Digest,NTLM", description = "Proxy authentication method to use") private String proxyAuthMethod; diff --git a/components/camel-http-common/src/main/java/org/apache/camel/http/common/HttpConfiguration.java b/components/camel-http-common/src/main/java/org/apache/camel/http/common/HttpConfiguration.java index c0a404ab59cc1..de4f1ebc292a5 100644 --- a/components/camel-http-common/src/main/java/org/apache/camel/http/common/HttpConfiguration.java +++ b/components/camel-http-common/src/main/java/org/apache/camel/http/common/HttpConfiguration.java @@ -49,7 +49,9 @@ public class HttpConfiguration implements Serializable { private String proxyHost; @Metadata(label = "producer,proxy", description = "Proxy port to use") private int proxyPort; - @Metadata(label = "producer,proxy", enums = "http,https", description = "Authentication scheme to use") + @Metadata(label = "producer,proxy", enums = "http,https", defaultValue = "http", + description = "Proxy server connection protocol scheme. Defaults to http regardless of the target endpoint scheme," + + " because most corporate HTTP proxies expect a plain HTTP connection on their listener port.") private String proxyAuthScheme; @Metadata(label = "producer,proxy", enums = "Basic,Digest,NTLM", description = "Proxy authentication method to use") private String proxyAuthMethod; diff --git a/components/camel-http/src/main/java/org/apache/camel/component/http/HttpComponent.java b/components/camel-http/src/main/java/org/apache/camel/component/http/HttpComponent.java index 23c4138dcd57a..ef5c1e84a96e6 100644 --- a/components/camel-http/src/main/java/org/apache/camel/component/http/HttpComponent.java +++ b/components/camel-http/src/main/java/org/apache/camel/component/http/HttpComponent.java @@ -131,7 +131,16 @@ public class HttpComponent extends HttpCommonComponent implements RestProducerFa protected Timeout responseTimeout = Timeout.ofMilliseconds(0); // proxy - @Metadata(label = "producer,proxy", enums = "http,https", description = "Proxy authentication protocol scheme") + @Metadata(label = "producer,proxy", description = "Proxy server host") + protected String proxyHost; + @Metadata(label = "producer,proxy", description = "Proxy server port") + protected Integer proxyPort; + @Metadata(label = "producer,proxy", description = "Comma-separated list of hosts that should bypass the proxy. " + + "Supports wildcards, e.g., localhost,*.example.com,192.168.*.") + protected String nonProxyHosts; + @Metadata(label = "producer,proxy", enums = "http,https", defaultValue = "http", + description = "Proxy server connection protocol scheme. Defaults to http regardless of the target endpoint scheme," + + " because most corporate HTTP proxies expect a plain HTTP connection on their listener port.") protected String proxyAuthScheme; @Metadata(label = "producer,proxy", enums = "Basic,Digest,NTLM", description = "Proxy authentication method to use") protected String proxyAuthMethod; @@ -221,9 +230,9 @@ protected HttpClientConfigurer createHttpClientConfigurer(Map pa configurer = getHttpClientConfigurer(); } HttpCredentialsHelper credentialsProvider = new HttpCredentialsHelper(); - configurer = configureBasicAuthentication(parameters, configurer, credentialsProvider); - configurer = configureHttpProxy(parameters, configurer, secure, credentialsProvider); - configurer = configureOAuth2Authentication(parameters, configurer); + configurer = configureBasicAuthentication(parameters, configurer, credentialsProvider, targetUri); + configurer = configureHttpProxy(parameters, configurer, credentialsProvider); + configurer = configureOAuth2Authentication(parameters, configurer, targetUri); return configurer; } @@ -270,12 +279,12 @@ private HttpClientConfigurer configureBasicAuthentication( } private HttpClientConfigurer configureHttpProxy( - Map parameters, HttpClientConfigurer configurer, boolean secure, + Map parameters, HttpClientConfigurer configurer, HttpCredentialsHelper credentialsProvider) { String proxyAuthScheme = getParameter(parameters, "proxyAuthScheme", String.class, getProxyAuthScheme()); if (proxyAuthScheme == null) { - // fallback and use either http or https depending on secure - proxyAuthScheme = secure ? "https" : "http"; + // proxy connection itself uses http by default regardless of the target endpoint scheme + proxyAuthScheme = "http"; } String proxyAuthHost = getParameter(parameters, "proxyAuthHost", String.class, getProxyAuthHost()); Integer proxyAuthPort = getParameter(parameters, "proxyAuthPort", Integer.class, getProxyAuthPort()); diff --git a/components/camel-http/src/main/java/org/apache/camel/component/http/HttpEndpoint.java b/components/camel-http/src/main/java/org/apache/camel/component/http/HttpEndpoint.java index d973ef3ca12b0..8113e5ef2f493 100644 --- a/components/camel-http/src/main/java/org/apache/camel/component/http/HttpEndpoint.java +++ b/components/camel-http/src/main/java/org/apache/camel/component/http/HttpEndpoint.java @@ -29,7 +29,6 @@ import org.apache.camel.Producer; import org.apache.camel.api.management.ManagedAttribute; import org.apache.camel.api.management.ManagedResource; -import org.apache.camel.http.base.HttpHelper; import org.apache.camel.http.base.cookie.CookieHandler; import org.apache.camel.http.common.HttpCommonEndpoint; import org.apache.camel.spi.Metadata; @@ -255,9 +254,9 @@ protected HttpClient createHttpClient() { String host = getCamelContext().getGlobalOption("http.proxyHost"); int port = Integer.parseInt(getCamelContext().getGlobalOption("http.proxyPort")); String scheme = getCamelContext().getGlobalOption("http.proxyScheme"); - // fallback and use either http or https depending on secure + // proxy connection uses http by default regardless of the target endpoint scheme if (scheme == null) { - scheme = HttpHelper.isSecureConnection(getEndpointUri()) ? "https" : "http"; + scheme = "http"; } LOG.debug( "CamelContext properties http.proxyHost, http.proxyPort, and http.proxyScheme detected. Using http proxy host: {} port: {} scheme: {}", diff --git a/components/camel-http/src/test/java/org/apache/camel/component/http/HttpProxyServerTest.java b/components/camel-http/src/test/java/org/apache/camel/component/http/HttpProxyServerTest.java index baa2ce1f52355..4029874a72d73 100644 --- a/components/camel-http/src/test/java/org/apache/camel/component/http/HttpProxyServerTest.java +++ b/components/camel-http/src/test/java/org/apache/camel/component/http/HttpProxyServerTest.java @@ -16,6 +16,7 @@ */ package org.apache.camel.component.http; +import java.lang.reflect.Field; import java.util.ArrayList; import java.util.HashMap; import java.util.List; @@ -26,6 +27,8 @@ import org.apache.camel.component.http.interceptor.RequestProxyBasicAuth; import org.apache.camel.component.http.interceptor.ResponseProxyBasicUnauthorized; import org.apache.camel.util.URISupport; +import org.apache.hc.client5.http.impl.classic.HttpClientBuilder; +import org.apache.hc.core5.http.HttpHost; import org.apache.hc.core5.http.HttpRequestInterceptor; import org.apache.hc.core5.http.HttpResponseInterceptor; import org.apache.hc.core5.http.impl.bootstrap.HttpServer; @@ -36,6 +39,7 @@ import org.junit.jupiter.api.Test; import static org.apache.camel.component.http.HttpMethods.GET; +import static org.assertj.core.api.Assertions.assertThat; import static org.junit.jupiter.api.Assertions.assertEquals; public class HttpProxyServerTest extends BaseHttpTest { @@ -129,6 +133,30 @@ public void httpGetWithProxyOnComponent() { assertExchange(exchange); } + @Test + public void httpsTargetWithProxyDefaultsToHttpProxyScheme() throws Exception { + // CAMEL-24632: proxy scheme must default to "http" regardless of the target endpoint scheme + HttpEndpoint endpoint = context.getEndpoint( + "https://www.example.com?proxyHost=myproxy&proxyPort=8080", HttpEndpoint.class); + + HttpClientConfigurer configurer = endpoint.getHttpClientConfigurer(); + assertThat(configurer).isNotNull(); + + HttpClientBuilder builder = HttpClientBuilder.create(); + configurer.configureHttpClient(builder); + + Field proxyField = HttpClientBuilder.class.getDeclaredField("proxy"); + proxyField.setAccessible(true); + HttpHost proxy = (HttpHost) proxyField.get(builder); + + assertThat(proxy).isNotNull(); + assertThat(proxy.getHostName()).isEqualTo("myproxy"); + assertThat(proxy.getPort()).isEqualTo(8080); + assertThat(proxy.getSchemeName()) + .as("Proxy scheme must be http even when the target endpoint is https") + .isEqualTo("http"); + } + private String getHost() { return "127.0.0.1"; } From 94cbf5b028cb02ff674f6b795909bccf3ca3f351 Mon Sep 17 00:00:00 2001 From: Francois de Parscau Date: Wed, 9 Sep 2026 13:36:50 +0200 Subject: [PATCH 2/2] fix(DPE-3944): backport fix --- Jenkinsfile.talend | 1 + components/camel-http-common/pom.xml | 2 ++ .../apache/camel/component/http/HttpComponent.java | 11 ++--------- pom.xml | 7 ++++--- 4 files changed, 9 insertions(+), 12 deletions(-) diff --git a/Jenkinsfile.talend b/Jenkinsfile.talend index 444aa398cfe46..024e660ccf4c1 100644 --- a/Jenkinsfile.talend +++ b/Jenkinsfile.talend @@ -48,6 +48,7 @@ org.apache.camel:camel-drill,\ org.apache.camel:camel-dynamic-router,\ org.apache.camel:camel-file,\ org.apache.camel:camel-google-pubsub,\ +org.apache.camel:camel-http-common,\ org.apache.camel:camel-http,\ org.apache.camel:camel-infinispan,\ org.apache.camel:camel-jaxb,\ diff --git a/components/camel-http-common/pom.xml b/components/camel-http-common/pom.xml index d14d2af4d493f..c6e3630c073fa 100644 --- a/components/camel-http-common/pom.xml +++ b/components/camel-http-common/pom.xml @@ -31,8 +31,10 @@ Camel :: HTTP :: Common Camel HTTP common + ${revision} + ${camel-http-common.tesb.version} 2.16.0 diff --git a/components/camel-http/src/main/java/org/apache/camel/component/http/HttpComponent.java b/components/camel-http/src/main/java/org/apache/camel/component/http/HttpComponent.java index ef5c1e84a96e6..a146086228095 100644 --- a/components/camel-http/src/main/java/org/apache/camel/component/http/HttpComponent.java +++ b/components/camel-http/src/main/java/org/apache/camel/component/http/HttpComponent.java @@ -131,13 +131,6 @@ public class HttpComponent extends HttpCommonComponent implements RestProducerFa protected Timeout responseTimeout = Timeout.ofMilliseconds(0); // proxy - @Metadata(label = "producer,proxy", description = "Proxy server host") - protected String proxyHost; - @Metadata(label = "producer,proxy", description = "Proxy server port") - protected Integer proxyPort; - @Metadata(label = "producer,proxy", description = "Comma-separated list of hosts that should bypass the proxy. " - + "Supports wildcards, e.g., localhost,*.example.com,192.168.*.") - protected String nonProxyHosts; @Metadata(label = "producer,proxy", enums = "http,https", defaultValue = "http", description = "Proxy server connection protocol scheme. Defaults to http regardless of the target endpoint scheme," + " because most corporate HTTP proxies expect a plain HTTP connection on their listener port.") @@ -230,9 +223,9 @@ protected HttpClientConfigurer createHttpClientConfigurer(Map pa configurer = getHttpClientConfigurer(); } HttpCredentialsHelper credentialsProvider = new HttpCredentialsHelper(); - configurer = configureBasicAuthentication(parameters, configurer, credentialsProvider, targetUri); + configurer = configureBasicAuthentication(parameters, configurer, credentialsProvider); configurer = configureHttpProxy(parameters, configurer, credentialsProvider); - configurer = configureOAuth2Authentication(parameters, configurer, targetUri); + configurer = configureOAuth2Authentication(parameters, configurer); return configurer; } diff --git a/pom.xml b/pom.xml index f425c4869d91c..5ba8ce03faccd 100644 --- a/pom.xml +++ b/pom.xml @@ -138,7 +138,8 @@ 4.8.1.20250320 4.8.1.20250320 4.8.1.20260608 - 4.8.1.20250320 + 4.8.1.20260909 + 4.8.1.20260909 4.8.1.20260608 4.8.1.20250320 4.8.1.20260608 @@ -179,8 +180,8 @@ 4.8.1.20250320 4.8.1.20250320 4.8.1.20250320 - 4.8.1.20260608 - 4.8.1.20260608 + 4.8.1.20260909 + 4.8.1.20260909 4.8.1.20250320 4.8.1.20250320 4.8.1.20250320