None of the previous answers worked for me using Spring 5 in the situation where I don't control the code making the http connection.
The following code disables SSL Certificate verification for all new RestTemplates:
@Beanpublic RestTemplateCustomizer restTemplateCustomizer() { return restTemplate -> { try { SSLContext sslContext = SSLContextBuilder.create() .loadTrustMaterial((TrustStrategy) (chain, authType) -> true) .build(); SSLConnectionSocketFactory socketFactory = new SSLConnectionSocketFactory( sslContext, NoopHostnameVerifier.INSTANCE); PoolingHttpClientConnectionManager connectionManager = PoolingHttpClientConnectionManagerBuilder.create() .setSSLSocketFactory(socketFactory) .build(); CloseableHttpClient httpClient = HttpClients.custom() .setConnectionManager(connectionManager) .build(); HttpComponentsClientHttpRequestFactory requestFactory = new HttpComponentsClientHttpRequestFactory(httpClient); restTemplate.setRequestFactory(requestFactory); } catch (Exception e) { e.printStackTrace(); } };