尽管在java cacerts中导入证书,但SSL握手失败错误

时间:2016-06-09 05:57:56

标签: java eclipse rest ssl

我试图使用REST api获取一些数据。我正在使用apache的http客户端。但是,每当我尝试连接时,它都会显示我的SSL握手失败'

我做的是: 1.从chrome中,下载网站的证书。它具有以下层次结构中的3个证书

-- Cert 3
  --Cert 2
    -- Cert 1 
  1. 接下来,我在Java JRE
  2. 下的我的证书文件夹中运行了这个命令

    keytool -keystore cacerts -importcert -alias para1 -file Cert1.cer
    keytool -keystore cacerts -importcert -alias para2 -file Cert2.cer
    keytool -keystore cacerts -importcert -alias para3 -file Cert3.cer

    此步骤成功

    1. 我关闭并重新打开了Eclipse,但错误并没有消失。

      • 我缺少哪些刷新功能可以使用更新的密钥库?
      • 或者我应该导入整个链并以某种方式链接它们而不是单独导入它们。
    2. 这是堆栈跟踪:

      javax.net.ssl.SSLHandshakeException: Received fatal alert: handshake_failure
          at sun.security.ssl.Alerts.getSSLException(Unknown Source)
          at sun.security.ssl.Alerts.getSSLException(Unknown Source)
          at sun.security.ssl.SSLSocketImpl.recvAlert(Unknown Source)
          at sun.security.ssl.SSLSocketImpl.readRecord(Unknown Source)
          at sun.security.ssl.SSLSocketImpl.performInitialHandshake(Unknown Source)
          at sun.security.ssl.SSLSocketImpl.writeRecord(Unknown Source)
          at sun.security.ssl.AppOutputStream.write(Unknown Source)
          at java.io.BufferedOutputStream.flushBuffer(Unknown Source)
          at java.io.BufferedOutputStream.flush(Unknown Source)
          at org.apache.commons.httpclient.HttpConnection.flushRequestOutputStream(HttpConnection.java:828)
          at org.apache.commons.httpclient.HttpMethodBase.writeRequest(HttpMethodBase.java:2116)
          at org.apache.commons.httpclient.HttpMethodBase.execute(HttpMethodBase.java:1096)
          at org.apache.commons.httpclient.HttpMethodDirector.executeWithRetry(HttpMethodDirector.java:398)
          at org.apache.commons.httpclient.HttpMethodDirector.executeMethod(HttpMethodDirector.java:171)
          at org.apache.commons.httpclient.HttpClient.executeMethod(HttpClient.java:397)
          at org.apache.commons.httpclient.HttpClient.executeMethod(HttpClient.java:323)
          at Upload.get(Get.java:124)
          at Upload.main(Get.java:63)
      

0 个答案:

没有答案