我无法与Jetty中的http客户端建立成功连接到本地网络中的https服务器。
卷曲一切正常:
curl -X POST 'https://local-network.ip/rest/link' -H 'Authorization: Bearer some_long_key' -H 'Content-Type: text/plain' -H 'Accept: application/json' -d '15' --compressed --insecure
现在我想在Java上使用Jetty实现相同的功能,但这会导致异常。 方法:
SslContextFactory sslContextFactory = new SslContextFactory(true);
HttpClient httpClient = new HttpClient(sslContextFactory);
httpClient.start();
System.setProperty("jsse.enableSNIExtension", "false"); // Needed to get rid of another exception
String requestAddress = "https://local-network.ip/rest/link";
Request request = httpClient.POST(requestAddress);
request.header(HttpHeader.ACCEPT, "application/json");
request.header(HttpHeader.CONTENT_TYPE, "text/plain");
String authHeader = "Bearer " + authKey;
request.header("Authorization", authHeader);
request.content(new StringContentProvider("15"));
try {
ContentResponse response = request.send();
} catch (InterruptedException | TimeoutException | ExecutionException e) {
}
System.setProperty("jsse.enableSNIExtension", "true");
httpClient.stop();
导致
javax.net.ssl.SSLHandshakeException:收到致命警报:不幸的是handshake_failure
我希望有人可以提供帮助,也许有想法如何追踪这一点?