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

AutoConfigureHttpClient RestTemplate with InterceptingClientHttpRequestFactory #1868

Closed
nkolosnjaji opened this issue Feb 8, 2023 · 4 comments · Fixed by #1869
Closed

AutoConfigureHttpClient RestTemplate with InterceptingClientHttpRequestFactory #1868

nkolosnjaji opened this issue Feb 8, 2023 · 4 comments · Fixed by #1869
Labels
Milestone

Comments

@nkolosnjaji
Copy link
Contributor

Is your feature request related to a problem? Please describe.
If user defines RestTemplate with interceptor (built with RestTemplateBuilder and HttpComponentsClientHttpRequestFactory), @AutoConfigureHttpClient will not setup "relaxed SSL validation". This is because restTemplate.getRequestFactory() will return wrapper of InterceptingClientHttpRequestFactory.

Describe the solution you'd like
@AutoConfigureHttpClient will check also InterceptingClientHttpRequestFactory if it's wrapping instance of HttpComponentsClientHttpRequestFactory.class

I can submit PR.

@marcingrzejszczak
Copy link
Contributor

Why are you filing this issue in Spring Cloud Contract project?

@nkolosnjaji
Copy link
Contributor Author

nkolosnjaji commented Feb 8, 2023

org.springframework.cloud.contract.wiremock.AutoConfigureHttpClient is part of spring-cloud-contract-wiremock which is importing WireMockRestTemplateConfiguration. It would be nice if RestTemplateBuilder is already configured with SSL relaxed validation when used in combination with RestTemplate interceptors.

RestTemplate with interceptors will not configure this, as per this code:

https://github.com/spring-cloud/spring-cloud-contract/blob/v4.0.1/spring-cloud-contract-wiremock/src/main/java/org/springframework/cloud/contract/wiremock/WireMockRestTemplateConfiguration.java#L51

and

https://github.com/spring-projects/spring-framework/blob/v6.0.4/spring-web/src/main/java/org/springframework/http/client/support/InterceptingHttpAccessor.java#L105

@marcingrzejszczak
Copy link
Contributor

I think I need more sleep - I've completely forgotten about that class. Yes, definitely we're interested in this PR.

@nkolosnjaji
Copy link
Contributor Author

I will create PR this days, thanks a lot!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants