Last active
December 9, 2021 07:08
-
-
Save slezicz/96361bac3cc049f0de17 to your computer and use it in GitHub Desktop.
Rest Template SSL trust self signed certificate
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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