javax.net.ssl.SSLHandshakeException:握手期间远程主机关闭连接

时间:2016-08-31 11:17:42

标签: java ssl tomcat6 jnlp java-security

我正在推出从我的网络应用程序下载的JNLP。 在收到Java安全警告提示提示后,如果用户响应在2-3秒内,则应用程序可以成功运行。但是,如果用户花了3秒多的时间来响应Java安全警告提示,则应用程序无法运行,并出现以下套接字异常错误:

 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.http.HttpURLConnection.getInputStream

(HttpURLConnection.java:1300)
    at sun.net.www.protocol.https.HttpsURLConnectionImpl.getInputStream

(HttpsURLConnectionImpl.java:254)
    at com.sun.deploy.net.HttpUtils.followRedirects(Unknown Source)
    at com.sun.deploy.net.BasicHttpRequest.doRequest(Unknown Source)
    at com.sun.deploy.net.BasicHttpRequest.doGetRequestEX(Unknown Source)
    at com.sun.deploy.cache.ResourceProviderImpl.checkUpdateAvailable

(Unknown Source)
    at com.sun.deploy.cache.ResourceProviderImpl.isUpdateAvailable(Unknown 

Source)
    at com.sun.deploy.cache.ResourceProviderImpl.getResource(Unknown Source)
    at com.sun.deploy.cache.ResourceProviderImpl.getResource(Unknown Source)
    at com.sun.javaws.LaunchDownload$DownloadTask.call(Unknown Source)
    at java.util.concurrent.FutureTask.run(FutureTask.java:262)
    at java.util.concurrent.ThreadPoolExecutor.runWorker

(ThreadPoolExecutor.java:1145)
    at java.util.concurrent.ThreadPoolExecutor$Worker.run

(ThreadPoolExecutor.java:615)
    at java.lang.Thread.run(Thread.java:745)
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)
    ... 19 more

Java Security Warning

Exception

附加信息:我已经检查了端口,他们指向正确的端口号,并且TLS值也匹配。证书也在cacerts下添加。

问题:当安全提示响应超过3-5秒时,导致异常的原因是什么?如何避免上述异常(可能增加等待时间)?

已完成的操作: 1.在Tomcat连接器中添加connectionTimeout属性,但是,在等待响应Java安全警告5秒后,应用程序仍然无法启动。

2 个答案:

答案 0 :(得分:1)

这最容易通过https.protocols系统属性进行控制。这是您能够控制工厂方法返回的方式。设置为" TLSv1"例如。

当您想要使用两个协议而不是一个协议时,会导致问题。例如,SSLv3和TLSv1。如果您尝试连接SSLv3或TLSv1,则此-Dhttps.protocols = TLSv1,SSLv3将导致异常。

请检查此答案。 How to make Java 6, which fails SSL connection with "SSL peer shut down incorrectly", succeed like Java 7?

答案 1 :(得分:0)

我遇到了同样的问题,然后我从JRE1.7切换到JRE1.8当然是因为TLS1.2 More references