我得到一个“线程中的异常”主要“javax.net.ssl.SSLHandshakeException:收到致命警报:handshake_failure”,代码如下。有人知道如何解决它吗?
import java.io.IOException;
import java.net.HttpURLConnection;
import java.net.MalformedURLException;
import java.net.URL;
import javax.net.ssl.HostnameVerifier;
import javax.net.ssl.HttpsURLConnection;
import javax.net.ssl.SSLSession;
public class Test {
static {
System.setProperty("https.protocols", "TLSv1,TLSv1.1,TLSv1.2,SSLv3,SSLv2Hello");
HostnameVerifier hv = new HostnameVerifier() {
public boolean verify(String urlHostName, SSLSession session) {
return true;
}
};
HttpsURLConnection.setDefaultHostnameVerifier(hv);
}
public static void main(String[] args) throws MalformedURLException, IOException {
HttpURLConnection con = (HttpsURLConnection) new URL("https://www.sureworks.de").openConnection();
con.connect();
}
}
答案 0 :(得分:0)
默认情况下,有一些与加密相关的内容未启用。您需要安装JCE:
PS:SSL实验室让您了解您尝试访问的服务器https://www.ssllabs.com/ssltest/analyze.html?viaform=on&d=https%3A%2F%2Fwww.sureworks.de%2F