Skip to content

AutoConfiguredRestClientSsl overwrites configuration from HttpClientProperties #43618

Closed as not planned
@kzander91

Description

@kzander91

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.

Metadata

Metadata

Assignees

No one assigned

    Labels

    status: supersededAn issue that has been superseded by another

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions