Created
July 28, 2022 13:26
-
-
Save panser/75687121f848af24af03c0d46907f466 to your computer and use it in GitHub Desktop.
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
public static ClientHttpRequestFactory httpRequestFactoryWithoutSsl() { | |
TrustStrategy acceptingTrustStrategy = (x509Certificates, s) -> true; | |
SSLContext sslContext = null; | |
try { | |
sslContext = org.apache.http.ssl.SSLContexts.custom().loadTrustMaterial(null, acceptingTrustStrategy).build(); | |
} catch (NoSuchAlgorithmException | KeyManagementException | KeyStoreException e) { | |
log.error("problem with creating no-ssl context"); | |
} | |
SSLConnectionSocketFactory csf = new SSLConnectionSocketFactory(sslContext, new NoopHostnameVerifier()); | |
CloseableHttpClient httpClient = HttpClients.custom().setSSLSocketFactory(csf).build(); | |
HttpComponentsClientHttpRequestFactory requestFactory = new HttpComponentsClientHttpRequestFactory(); | |
requestFactory.setHttpClient(httpClient); | |
return requestFactory; | |
} | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment