Describe the bug Please provide details of the problem, including the version of Spring Cloud that you are using.

Spring Cloud Netflix Client 3.0.0

We are trying to provide our own EurekaClientHttpRequestFactorySupplier bean with enhanced capabilities around a custom credential provider. However, this is never actually used in the RestTemplateTransportClientFactory.restTemplate() method unless we configure SslContext via the TlsProperties. However, we have no need for custom SslContext/TlsProperties and seems like a bug that RestTemplateTransportClientFactory.restTemplate() is checking for the presence of the SslContext in order make use of the configured EurekaClientHttpRequestFactorySupplier.

It seems that the DefaultEurekaClientHttpRequestFactorySupplier.get(SSLContext sslContext, @Nullable HostnameVerifier hostnameVerifier) method could be changed to safely handle if the sslContext argument is null and simply not set the HttpClientBuild.setSSLContext(sslContext) in that scenario or set it to SslContext.getDefault(). It is already doing this for the hostnameVerifier argument checking for null and only setting the HttpClientBuilder.setSSLHostnameVerifier(hostnameVerifier) in the event it isn't null. Thus, RestTemplateTransportClientFactory should be able to consistently create a RestTemplate passing the ClientHttpRequestFactory from the EurekaClientHttpRequestFactorySupplier.get(SSLContext sslContext, @Nullable HostnameVerifier hostnameVerifier) which seems to have been the original intention of exposing that bean and allowing the developer to substitute their own instead of just getting a new RestTemplate() that has no enhanced capabilities.

Sample If possible, please provide a test case or sample application that reproduces the problem. This makes it much easier for us to diagnose the problem and to verify that we have fixed it.

Comment From: ryanjbaxter

Makes sense. Would you be interested in creating a PR?