Issue with StdHttpClient reusing the connections with custom SSLFactory.

22 views
Skip to first unread message

herna...@gmail.com

unread,
Jan 30, 2018, 5:28:04 PM1/30/18
to ektorp-discuss
Hi,

I've been using a wrapper that enables TLS Mutual Authorization around CouchDB. From the client to connecto to this CouchDB I had to set the custom SSL Factory to send the right keys and so on. I'm adding the code below. The issue that showed up is that the client is not reusing/pooling the connections anymore when SSL is enabled and custom SSL Factory is configured in it. The wrapper around couchDB (which is actually Bluemix Secure Gateway in case it matters) let's me monitor incoming connections, and I can see that each call from the client generates a new connection, something that doesn't happen with SSL turned off. 

Anyone can give me a hint on how to fix this? I've discarded it's the wrapper fault since it works without problem with okhttp3 calls. I know that some people use the Apache HttpClient instead of Ektorp StdHttpClient. Any code on how to do that?

Here's my current code:

     

  @PostConstruct

 

 
private void init() throws KeyStoreException, NoSuchAlgorithmException, CertificateException, IOException, KeyManagementException, UnrecoverableKeyException {


 
}

 

 
private KeyStore loadKeyStore() throws IOException, KeyStoreException, NoSuchAlgorithmException, CertificateException {

 
KeyStore keyStore = KeyStore.getInstance(KeyStore.getDefaultType());

 
InputStream instream = this.keyStoreResource.getInputStream();

 keyStore
.load(instream, keyStorePassword.toCharArray());

 instream
.close();

 
return keyStore;

 
}


Thanks in advance, Hernan

Hernan Pepe Petersen

unread,
Feb 1, 2018, 7:35:58 AM2/1/18
to ektorp-discuss
I've found the code to it here: https://github.com/cloudant/java-cloudant/blob/master/cloudant-client/src/main/java/com/cloudant/client/api/ClientBuilder.java

Line 357. Just use the custom SSL factory to create an interceptor and add it to the properties.

props.addRequestInterceptors(new SSLCustomizerInterceptor(yourCustomSSLFactory));

Good luck
Reply all
Reply to author
Forward
0 new messages