我试图使用REST api获取一些数据。我正在使用apache的http客户端。但是,每当我尝试连接时,它都会显示我的SSL握手失败'
我做的是: 1.从chrome中,下载网站的证书。它具有以下层次结构中的3个证书
-- Cert 3
--Cert 2
-- Cert 1
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
此步骤成功
我关闭并重新打开了Eclipse,但错误并没有消失。
这是堆栈跟踪:
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)