wbhglfei
wbhglfei
2016-05-03 07:21
采纳率: 100%
浏览 2.8k
已采纳

求助,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 2016-05-03 08:32
    已采纳
    点赞 评论

相关推荐