On Tue, 2016-08-23 at 21:41 -0400, Sachin Nikumbh wrote: > Hello, > > I am working on a client application that is using > both CloseableHttpAsyncClient and CloseableHttpClient with HTTPS. My > application is sending a POST request with large amount of data and bunch > of GET requests as well. I was initially using CloseableHttpAsyncClient for > all the requests and everything was working fine with HTTPS. I recently > changed my code to use CloseableHttpClient just for the POST request. Now, > for the same client and server certificates (self signed), the SSL > handshake for POST is failing with error: > > Host name 'localhost' does not match the certificate subject provided by > the peer (C=US, ST=MA, L=Natick, O=Mathworks, OU=MPS_QE, CN=localhost) > > As can be seen, the CN of the server certificate is localhost. Following is > the code that I am using to create CloseableHttpClient : > > SSLConnectionSocketFactory sslFactory = new > SSLConnectionSocketFactory(sslContext, hostnameVerifier); > CloseableHttpClient httpClient = HttpClients.custom() > .setUserAgent(ApacheHttpClient.class.getName()) > .setSSLSocketFactory(sslFactory) > .build(); > > In the above code, sslContext is created using custom truststore and > keystore using system properties > like javax.net.ssl.keyStore, javax.net.ssl.trustStore, etc. The > hostnameVerifier's verify method is returning false. I have a feeling that > I am doing something wrong in the way I am setting up the > CloseableHttpClient. > > Could using CloseableHttpAsyncClient and CloseableHttpClient in the same > application to use HTTPS cause any issues? >
I cannot think of any reason why it would Conceptually however using two clients instead of one sounds somehow wrong to me. Oleg --------------------------------------------------------------------- To unsubscribe, e-mail: httpclient-users-unsubscr...@hc.apache.org For additional commands, e-mail: httpclient-users-h...@hc.apache.org