use of org.apache.hc.core5.http.config.RegistryBuilder in project geo-platform by geosdi.
the class GPServerProxy method createClientConnectionManager.
/**
* @return {@link HttpClientConnectionManager}
*/
HttpClientConnectionManager createClientConnectionManager() {
try {
SSLContextBuilder builder = new SSLContextBuilder();
builder.loadTrustMaterial(null, (chain, authType) -> true);
SSLConnectionSocketFactory sslSF = new SSLConnectionSocketFactory(builder.build(), NoopHostnameVerifier.INSTANCE);
PoolingHttpClientConnectionManager cm = new PoolingHttpClientConnectionManager(RegistryBuilder.<ConnectionSocketFactory>create().register("http", PlainConnectionSocketFactory.getSocketFactory()).register("https", sslSF).build());
cm.setMaxTotal(10);
cm.setDefaultMaxPerRoute(3);
return cm;
} catch (Exception ex) {
ex.printStackTrace();
throw new IllegalStateException(ex);
}
}
use of org.apache.hc.core5.http.config.RegistryBuilder in project commercetools-jvm-sdk by commercetools.
the class IntegrationTest method createNoSSLClient.
private static CloseableHttpAsyncClient createNoSSLClient() {
final TrustStrategy acceptingTrustStrategy = (X509Certificate[] chain, String authType) -> true;
try {
final SSLContext sslContext = SSLContexts.custom().loadTrustMaterial(null, acceptingTrustStrategy).build();
Lookup<TlsStrategy> socketFactoryRegistry = RegistryBuilder.<TlsStrategy>create().register("https", new DefaultClientTlsStrategy(sslContext, NoopHostnameVerifier.INSTANCE)).build();
PoolingAsyncClientConnectionManager connManager = new PoolingAsyncClientConnectionManager(socketFactoryRegistry);
return HttpAsyncClients.createMinimal(connManager);
} catch (Exception e) {
logger.error("Could not create SSLContext", e);
return null;
}
}
Aggregations