weblogic SSL证书错误 FATAL Alert:BAD_CERTIFICATE - A corrupt or unuseable certificat

weblogic服务器中通过HTTPS请求其他服务提示错误信息 weblogic SSL证书错误 FATAL Alert:BAD_CERTIFICATE - A corrupt or unuseable certificat。Certificate chain received from 客户端- 192.168.10.10 was not trusted causing SSL handshake failure

整个问题整整困扰了我一周如今终于解决,现在讲解决方式分享给大家借鉴。

提示错误 Certificate chain received from 客户端- 192.168.10.10 was not trusted causing SSL handshake failure。这个错误说明没有将证书导入到weblogic信任证书库中,可通过如下命令操作

导入:keytool -import -alias abc -keystore ..\lib\security\cacerts -file ..\lib\security\abc.cer -trustcacerts

查看:keytool -list -keystore ..\lib\security\cacerts

删除:keytool -delete -alias abc -keystore ..\lib\security\cacerts

密码默认为:changeit


将证书导入至weblogic证书库中后再测试可能会提示错误 FATAL Alert:BAD_CERTIFICATE - A corrupt or unuseable certificat

可能错误原因证书非CA认证证书,设置weblogic不对证书进行安全检查 -Dweblogic.StdoutDebugEnabled=true(startWeblogic.cmd正设置)

 可能原因源代码不能兼容weblogic中的jar,设置-DUseSunHttpHandler=true (startWeblogic.cmd正设置)

 

如果还不行,尝试设置如下参数:

-Dweblogic.security.SSL.allowSmallRSAExponent=true 

-Dweblogic.security.SSL.enforceConstraints=off 

-Dweblogic.security.SSL.ignoreHostnameVerification=true 

-Dweblogic.StdoutDebugEnabled=true -Dssl.debug 

-Dweblogic.security.SSL.ignoreHostnameVerification=true 

-Dssl.SocketFactory.provider=weblogic.security.SSL.SSLSocketFactory

 

-Dweblogic.webservice.client.ssl.strictcertchecking=false

 

 

第二种解决方案:

1、在源代码中使用sun的HttpHander

 

 

java.net.URL aURL = new java.net.URL(null, commURL, new sun.net.www.protocol.https.Handler());
 2、信任所有SSL证书

 

 

private void trustALLSSLCertificates(HttpURLConnection con) throws NoSuchAlgorithmException, KeyManagementException {
        ((HttpsURLConnection) con).setHostnameVerifier(new HostnameVerifier() {
            public boolean verify(String hostname, SSLSession session) {
                return true;
            }
        });
        // Ignore Certification
        TrustManager ignoreCertificationTrustManger = new X509TrustManager() {

            public void checkClientTrusted(X509Certificate certificates[], String authType) throws CertificateException {

            }

            public void checkServerTrusted(X509Certificate[] ax509certificate, String s) throws CertificateException {

            }

            public X509Certificate[] getAcceptedIssuers() {
                return null;
            }

        };
        // Prepare SSL Context
        TrustManager[] tm = { ignoreCertificationTrustManger };
        SSLContext sslContext = SSLContext.getInstance("SSL");
        sslContext.init(null, tm, new java.security.SecureRandom());

        // 从上述SSLContext对象中得到SSLSocketFactory对象
        SSLSocketFactory ssf = sslContext.getSocketFactory();
        ((HttpsURLConnection) con).setSSLSocketFactory(ssf);

    }
 
  • 0
    点赞
  • 1
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值