I'm trying to use Apache HttpAsyncClient with HTTP pipelining support. I want to add a trust-all SSL strategy similar to what's discussed here Ignoring SSL certificate in Apache HttpClient 4.3 (and a bunch of other places). But I don't see any way to get a pipelining client builder using the custom SSLContext: the HttpAsyncClients.createPipelining()
method doesn't return a builder, and HttpAsyncClients.custom()
builder doesn't build a ClosableHttpPipeliningClient
This should probably do what you want
DefaultConnectingIOReactor ioReactor = new DefaultConnectingIOReactor(IOReactorConfig.DEFAULT);
SSLContext sslContext = SSLContexts.custom().loadTrustMaterial(new TrustStrategy() {
@Override
public boolean isTrusted(X509Certificate[] chain, String authType) throws CertificateException {
return true;
}
}).build();
PoolingNHttpClientConnectionManager cm = new PoolingNHttpClientConnectionManager(
ioReactor,
RegistryBuilder.<SchemeIOSessionStrategy>create()
.register("http", NoopIOSessionStrategy.INSTANCE)
.register("https", new SSLIOSessionStrategy(sslContext))
.build());
CloseableHttpPipeliningClient httpClient = HttpAsyncClients.createPipelining(cm);
httpClient.start();