I would like to use connection pooling with my Jersey 2.x rest clients. I have the following code:
ClientConfig clientConfig = new ClientConfig();
PoolingHttpClientConnectionManager connectionManager = new PoolingHttpClientConnectionManager();
connectionManager.setMaxTotal(100);
connectionManager.setDefaultMaxPerRoute(20);
clientConfig.property(ApacheClientProperties.CONNECTION_MANAGER, connectionManager);
clientConfig.connectorProvider(new ApacheConnectorProvider());
Client client = ClientBuilder.newBuilder()
.withConfig(clientConfig)
.sslContext(SslConfigurator.getDefaultContext())
.build();
But this does not work for sites that require a client certificate. If I don't use the PoolingHttpClientConnectionManager
(i.e. comment it out like this:)
//clientConfig.property(ApacheClientProperties.CONNECTION_MANAGER, connectionManager);
Then the client certificate is sent.
How can I setup the PoolingHttpClientConnectionManager
to use javax.net.ssl...
properties?
Use SSL socket factory configured with system properties