Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

AutoConfiguredRestClientSsl overwrites configuration from HttpClientProperties #43618

Open
kzander91 opened this issue Dec 26, 2024 · 0 comments
Labels
status: waiting-for-triage An issue we've not yet triaged

Comments

@kzander91
Copy link
Contributor

kzander91 commented Dec 26, 2024

This is similar to #36594 and #27360 but I'm not sure if a solution for those issues would also fix mine, so feel free to close this if you consider this to be a duplicate.

Issue: Configuration made through the spring.http.client properties is ignored if I use AutoConfiguredRestClientSsl. For example, configuration like

spring:
  http:
    client:
      redirects: dont_follow

does not work if I also have this:

@Bean
RestClientCustomizer clientCertConfigurer(RestClientSsl restClientSsl) {
    return builder -> builder.apply(restClientSsl.fromBundle("my-bundle"));
}

The reason for this is that AutoConfiguredRestClientSsl replaces the request factory and thus discards any configuration made via the spring.http.client properties:

return (builder) -> {
ClientHttpRequestFactorySettings settings = ClientHttpRequestFactorySettings.ofSslBundle(bundle);
ClientHttpRequestFactory requestFactory = this.clientHttpRequestFactoryBuilder.build(settings);
builder.requestFactory(requestFactory);
};

For this specific issue I can work around this by removing my RestClientCustomizer and use

spring:
  http:
    client:
      redirects: dont_follow
      ssl:
        bundle: "my-bundle"

instead, but this only works in this static scenario, if I needed some more sophisticated logic to determine the SSL bundle to use at runtime, this wouldn't work.

@spring-projects-issues spring-projects-issues added the status: waiting-for-triage An issue we've not yet triaged label Dec 26, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
status: waiting-for-triage An issue we've not yet triaged
Projects
None yet
Development

No branches or pull requests

2 participants