Skip to content

Instantly share code, notes, and snippets.

@slezicz
Last active December 9, 2021 07:08
Show Gist options
  • Save slezicz/96361bac3cc049f0de17 to your computer and use it in GitHub Desktop.
Save slezicz/96361bac3cc049f0de17 to your computer and use it in GitHub Desktop.
Rest Template SSL trust self signed certificate
final HttpComponentsClientHttpRequestFactory requestFactory = new HttpComponentsClientHttpRequestFactory();
SSLContextBuilder builder = new SSLContextBuilder();
builder.loadTrustMaterial(null, new TrustSelfSignedStrategy());
SSLConnectionSocketFactory sslsf = new SSLConnectionSocketFactory(builder.build());
CloseableHttpClient httpclient = HttpClients.custom().setSSLSocketFactory(sslsf).build();
requestFactory.setHttpClient(httpclient);
RestTemplate template = new RestTemplate(requestFactory);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment