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
Asked
Active
Viewed 261 times
0

Vadim Kotov
- 8,084
- 8
- 48
- 62

ykaganovich
- 14,736
- 8
- 59
- 96
-
Just... DON'T. There is a reason it is hard to do this. It is to prevent people from writing code that breaks Internet security. Bite the bullet and set up the necessary certificates. – Jim Garrison Nov 01 '17 at 01:11
-
This is for a test client in a test environment. This option exists on every HTTP client I've encountered so far, including Apache HttpClient, cURL, wget, and all browsers. It's very hard to imagine this limitation is there intentionally. – ykaganovich Nov 01 '17 at 03:13
1 Answers
1
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();

ok2c
- 26,450
- 5
- 63
- 71