javax.net.ssl.SSLException: SSLSocketFactory is null

六眼飞鱼酱① 提交于 2019-12-05 18:21:36

You can try forward slashes for the paths even on windows:

System.setProperty("javax.net.ssl.keyStoreType", "pkcs12");
System.setProperty("javax.net.ssl.trustStoreType", "jks");
System.setProperty("javax.net.ssl.keyStore","C:/ClientKeyStore/ClientKeyStore.p12");
System.setProperty("javax.net.ssl.trustStore","C:/ClientKeyStore/ClientKeyStore.keystore");
System.setProperty("javax.net.debug", "ssl");
System.setProperty("javax.net.ssl.keyStorePassword", "keystorepass");
System.setProperty("javax.net.ssl.trustStorePassword", "truststorepass");


SSLSocketFactory sslsocketfactory = (SSLSocketFactory) SSLSocketFactory.getDefault();

Is this all your code? Your properties look fine and I was able to use your example to create a socket factory.

I had this problem with my websphere 8.5 / ibm java 1.7 setup.

In my case it was caused by the JREs <JRE_HOME>\lib\security\java.security file.

In my case the file said...

ssl.KeyManagerFactory.algorithm=IbmX509
ssl.TrustManagerFactory.algorithm=PKIX

The PKIX value looked suspicious so I changed this line of the file to...

ssl.TrustManagerFactory.algorithm=IbmX509

When I restarted the websphere server the connection worked.

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!