2 wbhglfei wbhglfei 于 2016.05.03 15:21 提问

求助,java项目加载安全证书

项目中需要调用webService接口,走https,需要加载安全证书(项目部署在websphere上面)

 KeyStore ks = KeyStore.getInstance("JKS");
            InputStream is = null;
            try {
                is=new java.io.FileInputStream("/share/pengyuan/sqty.jks");
                ks.load(is, "password".toCharArray());
                java.security.cert.Certificate c = ks.getCertificate("server");
                logger.info("加载证书"+c.toString());
            } finally {
                if (is != null) {
                    is.close();
                }
            }
            System.setProperty("javax.net.ssl.keyStore", "/share/pengyuan/sqty.jks");
            System.setProperty("javax.net.ssl.keyStorePassword", "password");

后台日志记录到了
javax.net.ssl.SSLException: SSLSocketFactory is null. This can occur if javax.net.ssl.SSLSocketFactory.getDefault() is called to create a socket and javax.net.ssl.* properties are not set.

请问这个异常是代码中缺少什么内容还是需要在linux上面配置某些东西?

1个回答

oyljerry
oyljerry   Ds   Rxr 2016.05.03 16:32
已采纳
wbhglfei
wbhglfei 非常感谢,搜索了一天了!~
一年多之前 回复
Csdn user default icon
上传中...
上传图片
插入图片
准确详细的回答,更有利于被提问者采纳,从而获得C币。复制、灌水、广告等回答会被删除,是时候展现真正的技术了!