use of org.apache.hc.client5.http.ssl.SSLConnectionSocketFactory in project pact-jvm by DiUS.
the class HttpClient method insecureHttpClient.
static CloseableHttpClient insecureHttpClient() {
SSLContext sslContext = null;
try {
sslContext = SSLContexts.custom().loadTrustMaterial(new TrustSelfSignedStrategy()).build();
} catch (NoSuchAlgorithmException | KeyManagementException | KeyStoreException e) {
throw new RuntimeException(e);
}
SSLConnectionSocketFactory socketFactory = SSLConnectionSocketFactoryBuilder.create().setSslContext(sslContext).build();
CloseableHttpClient httpClient = HttpClientBuilder.create().setConnectionManager(new BasicHttpClientConnectionManager(RegistryBuilder.<ConnectionSocketFactory>create().register("http", PlainConnectionSocketFactory.getSocketFactory()).register("https", socketFactory).build())).build();
return httpClient;
}
Aggregations