Seshu Thota created CAMEL-25941:
-----------------------------------
Summary: camel-as2 - AS2 client should support sending through an
HTTP proxy
Key: CAMEL-25941
URL: https://issues.apache.org/jira/browse/CAMEL-25941
Project: Camel
Issue Type: Improvement
Components: camel-as2
Reporter: Seshu Thota
h3. Problem
The AS2 client endpoint cannot send messages through an HTTP proxy. Many AS2
deployments sit in networks where outbound traffic must go through a corporate
forward proxy, so today they cannot use camel-as2 for sending.
{{AS2ClientConnection}} does not use {{HttpClientBuilder}}. It drives HttpCore
/ {{PoolingHttpClientConnectionManager}} directly with {{new
HttpRoute(targetHost)}}, so HttpClient's route planning never runs. As a result:
* There is no endpoint option for a proxy.
* The JVM properties {{http.proxyHost}} / {{https.proxyHost}} have no effect.
* The test connection made in the {{AS2ClientConnection}} constructor
({{createTestConnection}}) opens a raw {{Socket}} straight to the target, so
behind a proxy-only egress the endpoint fails at startup.
h3. Proposal
Add proxy options to the AS2 client endpoint. Use the same names and semantics
as camel-http, which is built on the same HttpClient 5 library:
||Option||Type||Notes||
|proxyHost|String|Proxy server host. When it is not set, behaviour is
unchanged.|
|proxyPort|Integer|Proxy server port.|
|proxyAuthUsername|String|{{security = "secret"}}. Optional, for Basic proxy
authentication.|
|proxyAuthPassword|String|{{security = "secret"}}. Optional.|
Behaviour:
* *http target:* the request goes to the proxy with an absolute request-URI.
* *https target:* the client opens a CONNECT tunnel to
{{targetHostname:targetPortNumber}}, then runs TLS over the tunnel using the
endpoint's {{sslContext}}. The TLS hostname check uses the *target* host, not
the proxy host (see CAMEL-24379).
* The connection to the proxy itself is plain HTTP, whatever the target scheme.
This avoids the defaulting bug fixed in camel-http by CAMEL-24632.
* When credentials are set, a preemptive {{Proxy-Authorization: Basic ...}}
header is sent to the proxy only: on the CONNECT request for https, on each
request for http. The header is never sent to the AS2 partner.
* If the proxy refuses the request (e.g. 407), the send fails with an exception.
* The startup test connection also goes through the proxy.
h3. Out of scope / follow-ups
* *Asynchronous MDN delivery* ({{AS2AsynchronousMDNManager}}). The delivery
address is chosen by the sender of the AS2 message (the Receipt-Delivery-Option
header). Sending it through the operator's proxy changes which destinations a
remote sender can make Camel reach, so it deserves its own discussion and is
left out of this change.
* Digest / NTLM proxy authentication (NTLM is deprecated in camel-http).
* {{nonProxyHosts}}. An AS2 client endpoint has a single fixed target, so this
has little value here.
* No CamelContext global options ({{http.proxyHost}} style). These were
deprecated for camel-http in CAMEL-22346.
h3. Compatibility
These are new optional options and nothing changes when they are not set, so no
upgrade guide entry is needed. The new options will be documented in the AS2
component page.
h3. Prior art in Camel
* camel-http: {{proxyHost}}, {{proxyPort}}, {{proxyAuthUsername}},
{{proxyAuthPassword}} (CAMEL-15012, CAMEL-22345, CAMEL-22689, CAMEL-24632)
* camel-fhir / camel-vertx-http: {{proxyHost}}, {{proxyPort}}, plus
username/password marked {{security = "secret"}}
_Drafted with Claude Code on behalf of seshuthota_
--
This message was sent by Atlassian Jira
(v10.3.26#10030026)