我试图调用一个最近从HTTP更改为HTTPS的web服务,结果出现以下错误:
java.net.SocketException: Unexpected end of file from server
请注意,我遇到了证书问题,但我通过keytool在信任库中添加了证书,然后用以下命令设置系统属性:
System.setProperty("javax.net.ssl.trustStore", "C://Progra~1//Java//jdk1.8.0_201//jre//lib//security//cacerts");
System.setProperty("javax.net.ssl.trustStorePassword","changeit");
出现的错误:
main, handling exception: java.net.SocketException: Connection reset main, SEND TLSv1.2 ALERT: fatal, description = unexpected_message main, WRITE: TLSv1.2 Alert, length = 2 main,
Exception sending alert: java.net.SocketException: Connection reset by peer: socket write error main, called closeSocket()
提前感谢您的介入!
Adnane,当尝试运行客户端时,您可以设置额外的参数,该参数将打印与服务器的ssl连接协商的调试日志。
通过这种方式,您可以检查证书链是否正确,并排除它是否与证书相关。
-Djavax.net.debug=all