Skip to content

Apply disable-ssl-validation to the HTTP/2 client - #1462

Merged
ryanjbaxter merged 3 commits into
spring-cloud:mainfrom
rajeshvasa:gh-1196-http2-disable-ssl-validation
Nov 24, 2026
Merged

ryanjbaxter merged 3 commits into
spring-cloud:mainfrom
rajeshvasa:gh-1196-http2-disable-ssl-validation

Conversation

@rajeshvasa

@rajeshvasa rajeshvasa commented Nov 15, 2026 •

Copy link
Copy Markdown
Contributor

Fixes #1196

spring.cloud.openfeign.httpclient.disable-ssl-validation was only applied to the Apache HttpClient 5 client, and Http2ClientFeignConfiguration had no way to disable SSL validation, so with the JDK HTTP/2 client, calls to a server with an untrusted certificate always failed with an SSLHandshakeException.

Following the documented httpclient.hc5.* / httpclient.http2.* convention, the HTTP/2 client now has its own property, spring.cloud.openfeign.httpclient.http2.disable-ssl-validation. When it is true, the HttpClient.Builder is configured with an SSLContext whose trust manager accepts every certificate. It extends X509ExtendedTrustManager, so hostname verification is skipped as well, matching the Apache HttpClient 5 behavior. A warning is logged when the client is created with validation disabled.

The top-level httpclient.disable-ssl-validation still applies only to Apache HttpClient 5, so existing users who set it do not silently lose validation on the HTTP/2 client. The trust manager is now a shared package-private class used by both configurations. The docs and the configuration properties table are updated.

The issue also mentions the default client. That client is Feign's own Client.Default, created outside the auto-configured clients, so I kept this PR focused on the HTTP/2 client. Happy to follow up on the default client if you'd like.

Tests

  • New FeignHttp2ClientDisableSslValidationTests: starts a local HTTPS server with a self-signed certificate issued for a different host name (a new test keystore, http2-self-signed.p12), and checks that the HTTP/2 client connects and logs a warning when httpclient.http2.disable-ssl-validation=true, still fails with SSLHandshakeException by default, and is not affected by the top-level httpclient.disable-ssl-validation
  • Full spring-cloud-openfeign-core build passes locally, including checkstyle

spring.cloud.openfeign.httpclient.disable-ssl-validation was only applied
to the Apache HttpClient 5 client. Http2ClientFeignConfiguration never
read it, so with the JDK HTTP/2 client, calls to a server with an
untrusted certificate still failed with an SSLHandshakeException.

When the property is set, configure the HttpClient.Builder with an
SSLContext whose trust manager accepts every certificate. It extends
X509ExtendedTrustManager, so hostname verification is skipped as well,
matching the Apache HttpClient 5 behavior.

Fixes spring-cloudgh-1196

Signed-off-by: Rajesh Vasa <guptha.rh@gmail.com>

@ryanjbaxter ryanjbaxter left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We should also update the docs to state that the property effects the http2 client

* manager, so this also skips hostname verification, like the Apache HttpClient 5
* configuration does with its no-op hostname verifier.
*/
static class DisabledValidationTrustManager extends X509ExtendedTrustManager {

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can this class be shared with HttpClient5FeignConfiguration?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done in 100eee6: it's now a shared package-private DisabledValidationTrustManager class used by both configurations.

@rajeshvasa
rajeshvasa force-pushed the gh-1196-http2-disable-ssl-validation branch from 837740b to 8ccad9a Compare November 20, 2026 02:07
…cument HTTP/2 support

Address review feedback on spring-cloudgh-1196:

- Move DisabledValidationTrustManager to its own package-private class,
  shared by HttpClient5FeignConfiguration and Http2ClientFeignConfiguration.
  It extends X509ExtendedTrustManager, so the JDK HttpClient also skips
  hostname verification; Apache HttpClient 5 already skipped it with its
  no-op hostname verifier.
- Log a warning when the HTTP/2 client is created with
  disable-ssl-validation=true.
- Document that the property applies to the HTTP/2 client too, in the
  property description and the HTTP clients section.

Signed-off-by: Rajesh Vasa <guptha.rh@gmail.com>
@rajeshvasa
rajeshvasa force-pushed the gh-1196-http2-disable-ssl-validation branch from 8ccad9a to 100eee6 Compare November 20, 2026 02:07
@rajeshvasa

Copy link
Copy Markdown
Contributor Author

Thanks @ryanjbaxter! Updated:

  • DisabledValidationTrustManager is now a shared package-private class used by both HttpClient5FeignConfiguration and Http2ClientFeignConfiguration. It extends X509ExtendedTrustManager, so for HC5 behaviour is unchanged (it already skipped hostname verification with NoopHostnameVerifier).
  • The HTTP/2 client now logs a warning when it is created with SSL validation disabled; the test asserts it.
  • The docs now state that disable-ssl-validation applies to the HTTP/2 client, both in the property description and in the HTTP clients section.

Should HC5 log the same warning? Happy to add it.

@ryanjbaxter ryanjbaxter left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes a warning there also would be good


|===

`spring.cloud.openfeign.httpclient.disable-ssl-validation` applies to both Apache HttpClient 5 and the HTTP/2 (Java `HttpClient`) client. When it is `true`, server certificates and host names are not verified, and the HTTP/2 client logs a warning when it is created. Use it only for testing, never in production.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actually to be consistent with what the docs state

You can further customise http clients by setting values in the spring.cloud.openfeign.httpclient.xxx properties. The ones prefixed just with httpclient will work for all the clients, the ones prefixed with httpclient.hc5 to Apache HttpClient 5, and the ones prefixed with httpclient.http2 to Http2Client. You can find a full list of properties you can customise in the appendix.

We http/2 should have its own property

Address review feedback on spring-cloudgh-1196: to follow the documented httpclient.hc5.* / httpclient.http2.* convention, the HTTP/2 client now uses spring.cloud.openfeign.httpclient.http2.disable-ssl-validation instead of the top-level property. The top-level httpclient.disable-ssl-validation again applies only to Apache HttpClient 5, so existing users who set it do not silently lose validation on the HTTP/2 client.

Update the docs and configuration properties table, and add a test that the top-level property does not affect the HTTP/2 client.

Signed-off-by: Rajesh Vasa <guptha.rh@gmail.com>
@rajeshvasa

Copy link
Copy Markdown
Contributor Author

Thanks Ryan, that makes sense. I've moved it to its own property, spring.cloud.openfeign.httpclient.http2.disable-ssl-validation, so it follows the hc5.* / http2.* convention in the docs. The top-level httpclient.disable-ssl-validation now only affects Apache HttpClient 5, as before, so existing users who set it won't silently lose validation on the HTTP/2 client. The HTTP/2 client still logs a warning when it's enabled, the docs and config properties table are updated, and there's a test confirming the top-level property doesn't affect HTTP/2. Could you take another look when you have a moment?

@ryanjbaxter
ryanjbaxter merged commit 6728895 into spring-cloud:main Nov 24, 2026
2 checks passed
@rajeshvasa

Copy link
Copy Markdown
Contributor Author

Thanks for the review and merge, @ryanjbaxter!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

feign.httpclient.disable-ssl-validation = true doesn't disable ssl validation for HttpClient

3 participants