spring-cloud / spring-cloud-config

External configuration (server and client) for Spring Cloud
Apache License 2.0
1.96k stars 1.29k forks source link

Add RestTemplateCustomizer to ConfigServicePropertySourceLocator #1563

Open epm-dev-priporov opened 4 years ago

epm-dev-priporov commented 4 years ago

On the current project we use spring cloud config solution. The problem is that the config-server was deployed behind https load-balancer and we got the follfowing issues:

c.c.c.ConfigServicePropertySourceLocator : Could not locate PropertySource: I/O error on GET request for "****": java.security.cert.CertificateException: No subject alternative DNS name matching *** found.; nested exception is javax.net.ssl.SSLHandshakeException: java.security.cert.CertificateException: No subject alternative DNS name matching ***

According documentation we have solved that by custom ConfigServicePropertySourceLocator and RestTemplate configuration used there, but that was really tricky, we spend a few hours to find the proper client configuration.

The solution we'd like to have is just an opportunity to change RestTempalte config used in ConfigServicePropertySourceLocator via application.properties. In our case that could be something like spring.cloud.config.clinet.ssl.enalbed=false

ryanjbaxter commented 4 years ago

I think that might put us down a dangerous path of adding properties to customize RestTemplate and is not something I think we want to do.

spencergibb commented 4 years ago

@epm-dev-priporov can you tell us what was tricky with the documentation? We're going to eventually move on from WebClient. In the meantime, we'd like to improve the docs on custom rest templates.

epm-dev-priporov commented 4 years ago

@spencergibb The problem mostly was about RestTemplate configuration. But also what I didn't like is that in case custom ConfigServicePropertySourceLocator we had to manually add all properties, I would say that the method to setup custom RestTemplate can be improved somehow to avoid that.

spencergibb commented 4 years ago

How about a ConfigRestTemplateCustomizer that would then get everything done in ConfigServicePropertySourceLocator but let the user do what they need without having to do property driven development?

epm-dev-priporov commented 4 years ago

@spencergibb That would be good, but if you are planning to replace RestTemplate by WebClient, that's probably will not be so useful in the future. But the same approach for WebClient will be convenient.

spencergibb commented 4 years ago

It should be minor, while rest template eventually will be replaced, I think this is a good compromise and we would do something similar with webclient.

epm-dev-priporov commented 4 years ago

@spencergibb good, so should I close the issue?

spencergibb commented 4 years ago

No we'll keep it open to track the new enhancement.