Details
-
Bug
-
Status: Resolved
-
Blocker
-
Resolution: Invalid
-
None
-
None
-
None
-
Ubuntu with java 1.8
Description
I am trying to connect to a server which requires two way SSL authentication with apache CloseableHttpAsyncClient. I have provided the JVM with keystore and truststore using -Djavax.net.ssl.keyStore and -Djavax.net.ssl.trustStore. However, the client does not send the certificate to the server when asked. From the server side I keep getting the following exception.
javax.net.ssl.SSLHandshakeException: null cert chain
at sun.security.ssl.Alerts.getSSLException(Alerts.java:192)
at sun.security.ssl.SSLSocketImpl.fatal(SSLSocketImpl.java:1937)
at sun.security.ssl.Handshaker.fatalSE(Handshaker.java:302)
at sun.security.ssl.Handshaker.fatalSE(Handshaker.java:292)
at sun.security.ssl.ServerHandshaker.clientCertificate(ServerHandshaker.java:1804)
I have checked the packet trace and the server requests for the client certificate mentioning trusted authorities. But the client message for certificate contains a certificate of length 0. Same application has a SOAP client which also connects to the same server with two say SSL authentication which is working fine. Please find the code to initialize the http client below.
SSLContext sslContext;
try
catch (NoSuchAlgorithmException | KeyStoreException | KeyManagementException e)
{ logger.error("An error occurred while creating ssl context,", e); throw new RuntimeException(e); } SSLIOSessionStrategy sslSessionStrategy = new SSLIOSessionStrategy(
sslContext,
new String[]
,
null,
SSLIOSessionStrategy.getDefaultHostnameVerifier());
httpClient = HttpAsyncClients
.custom()
.setConnectionManager(connectionManager)
.setSSLHostnameVerifier(SSLConnectionSocketFactory.ALLOW_ALL_HOSTNAME_VERIFIER)
.setSSLStrategy(sslSessionStrategy)
.build();
httpClient.start();
I have tried registering ConnectionSocketFactory for http and SSLConnectionSocketFactory for https using ConnectionSocketFactory registry and it also did not work.