-
Notifications
You must be signed in to change notification settings - Fork 41.4k
Description
Apache HttpClient 5.4.x (in upcoming Spring Boot 3.4) has by default enabled HTTP/1.1 TLS Upgrade in apache/httpcomponents-client#542. This causes an issue for k8s deployments using Istio service mesh (and Envoy proxies) as described in istio/istio#53239 where outbound http requests will receive a HTTP status 403 with "upgrade_failed".
The issue has been reported to the Apache project in https://issues.apache.org/jira/browse/HTTPCLIENT-2344, where it has been closed as invalid since they believe Envoy is not behaving correctly.
The issue has been reported to Envoy in envoyproxy/envoy#36305 where discussions are ongoing.
Note that the protocol upgrade is only enabled for OPTIONS, HEAD and GET requests and clients may therefore observe that some requests work and others don't (Envoy will block the ones containing the TLS upgrade headers).
Code based workaround is to change protocolUpgradeEnabled to false when creating the HttpClient's RequestConfig.
RequestConfig requestConfig = RequestConfig.custom()
// ...
.setProtocolUpgradeEnabled(false)
.build();
HttpClient httpClient = HttpClientBuilder.create()
// ...
.setDefaultRequestConfig(requestConfig)
.build();
There is currently no system property in Apache HttpClient5 to disable protocolUpgradeEnable.
Should this known issue and possible workarounds be listed in the migration guide?
Not sure if a configuration option is a good possibility here, but HttpComponentsClientHttpRequestFactory
will currently by default try to use HttpClients.createSystem()
with protocolUpgrade enabled by default.