0

我尝试调用最近从 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()

提前感谢您的干预!

4

2 回答 2

1

Adnane,在尝试运行客户端时,您可以设置额外的参数,该参数将在与服务器的 ssl 连接协商中打印调试日志。

这样您可以检查证书链是否正确并排除它是否与证书有关。

-Djavax.net.debug=all
于 2020-06-22T14:39:14.217 回答
0

我通过将标题设置为解决了这个问题:

Map<String, Object> req_ctx = ((BindingProvider) port).getRequestContext();
    req_ctx.put(BindingProvider.ENDPOINT_ADDRESS_PROPERTY,wsdlURL.toString());          
    Map<String, List<String>> headers = new HashMap<String, List<String>>();
    headers.put("Content-Type", Collections.singletonList("text/xml"));        
    req_ctx.put(MessageContext.HTTP_REQUEST_HEADERS, headers);

内容类型是“应用程序/xml”。

于 2020-06-23T10:34:35.493 回答