Urgent : Unable to load Keystore
843811Nov 1 2006 — edited Nov 2 2006Hi,
I have HTTPS Client with client authendication
When I load my keystore using KeyManagerfactory the client is not sending its certificate to the server
and I am getting the below error in server
----------
Thread-0, handling exception: javax.net.ssl.SSLHandshakeException: null cert chain
IOException occurred when processing request.
------------
But If I load the keystore using system property as below it works fine , the client sends the certificate chain to the server
System.setProperty("javax.net.ssl.keyStoreType", "JKS");
System.setProperty("javax.net.ssl.keyStore", KEYSTORE);
System.setProperty("javax.net.ssl.keyStorePassword", "password");
But I want to load the Keystore using KeyManagerFactory.Can anyone tell whats wrong in the below code
---------------------------
Security.addProvider(new com.sun.net.ssl.internal.ssl.Provider());
System.setProperty("javax.net.debug", "all");
KeyManagerFactory kmf = KeyManagerFactory.getInstance("SunX509");
KeyStore keystore = KeyStore.getInstance("JKS");
keystore.load(new FileInputStream(KEYSTORE), KEYSTOREPW);
kmf.init(keystore, KEYPW);
TrustManagerFactory tmf = TrustManagerFactory.getInstance("SunX509");
KeyStore truststore = KeyStore.getInstance("jks");
truststore.load(new FileInputStream(TRUSTSTORE), TRUSTSTOREPW);
tmf.init(truststore);
SSLContext sslc = SSLContext.getInstance("SSLv3");
sslc.init(kmf.getKeyManagers(), tmf.getTrustManagers(), null);
HttpsURLConnection urlc = (HttpsURLConnection)new URL(urlString).openConnection();
urlc.setHostnameVerifier(new TrustAllHostnames());
urlc.setDefaultSSLSocketFactory(sslc.getSocketFactory());
BufferedReader reader = new BufferedReader(new InputStreamReader(urlc.getInputStream()));
String line;
-------------------
Thanks in advance,
Babu