Jsoup错误握手期间远程主机关闭连接

时间:2015-12-12 04:55:30

标签: jsoup

感谢您抽出时间阅读我的问题 - 我正在使用Eclipse IDE。 我希望Jsoup使用Document doc = Jsoup.connect("https://www.icegate.gov.in/").get();

连接https网址 - https://www.icegate.gov.in/

但它给出了错误Exception in thread "main" javax.net.ssl.SSLHandshakeException: Remote host closed connection during handshake,而当我为其他https(如linkedin)使用相同的代码时它可以工作......我不知道如何解决这个问题。

我获得了该网站的证书并安装在我的jre / lib / security文件夹中,但它也没有帮助我。

如何添加这些证书&日食中的jks。

这是我的代码:

public static void main(String[] args) throws IOException {

    Document doc = Jsoup.connect("https://www.linkedin.com/in/xxxxxx").get();

    Element summaryDetails = doc.getElementById("profile");


    System.out.println("Summary Details  is - "+ summaryDetails.text());

    Document doc2 = Jsoup.connect("https://www.icegate.gov.in/").get();
}

我得到的错误是:

Exception in thread "main" javax.net.ssl.SSLHandshakeException: Remote host closed connection during handshake
    at sun.security.ssl.SSLSocketImpl.readRecord(SSLSocketImpl.java:946)
    at sun.security.ssl.SSLSocketImpl.performInitialHandshake(SSLSocketImpl.java:1312)
    at sun.security.ssl.SSLSocketImpl.startHandshake(SSLSocketImpl.java:1339)
    at sun.security.ssl.SSLSocketImpl.startHandshake(SSLSocketImpl.java:1323)
    at sun.net.www.protocol.https.HttpsClient.afterConnect(HttpsClient.java:563)
    at sun.net.www.protocol.https.AbstractDelegateHttpsURLConnection.connect(AbstractDelegateHttpsURLConnection.java:185)
    at sun.net.www.protocol.https.HttpsURLConnectionImpl.connect(HttpsURLConnectionImpl.java:153)
    at org.jsoup.helper.HttpConnection$Response.execute(HttpConnection.java:512)
    at org.jsoup.helper.HttpConnection$Response.execute(HttpConnection.java:493)
    at org.jsoup.helper.HttpConnection.execute(HttpConnection.java:205)
    at org.jsoup.helper.HttpConnection.get(HttpConnection.java:194)
    at com.deepak.TestLinkedIn.main(TestLinkedIn.java:39)
Caused by: java.io.EOFException: SSL peer shut down incorrectly
    at sun.security.ssl.InputRecord.read(InputRecord.java:482)
    at sun.security.ssl.SSLSocketImpl.readRecord(SSLSocketImpl.java:927)

1 个答案:

答案 0 :(得分:1)

只需使用这些VM参数运行java:

-Dhttps.protocols=TLSv1.2 -Djsse.enableSNIExtension=false

这些其他问题的更多信息:

SSL handshake alert: unrecognized_name error since upgrade to Java 1.7.0

How to make Java 6, which fails SSL connection with "SSL peer shut down incorrectly", succeed like Java 7?

Bytheway,我不需要向我的信任库添加任何证书,因为站点证书的CA已经被信任。