获取请求 handshake_faliure:javax.net.ssl.SSLHandshakeException

Get request handshake_faliure:javax.net.ssl.SSLHandshakeException

向www.sunnyportal.com发送get请求时,控制台出现错误码,如下:

    javax.net.ssl.SSLHandshakeException: Received fatal alert: handshake_failure
at sun.security.ssl.Alerts.getSSLException(Alerts.java:192)
at sun.security.ssl.Alerts.getSSLException(Alerts.java:154)
at sun.security.ssl.SSLSocketImpl.recvAlert(SSLSocketImpl.java:1979)
at sun.security.ssl.SSLSocketImpl.readRecord(SSLSocketImpl.java:1086)
at sun.security.ssl.SSLSocketImpl.performInitialHandshake(SSLSocketImpl.java:1332)
at sun.security.ssl.SSLSocketImpl.startHandshake(SSLSocketImpl.java:1359)
at sun.security.ssl.SSLSocketImpl.startHandshake(SSLSocketImpl.java:1343)
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:1301)
at sun.net.www.protocol.https.HttpsURLConnectionImpl.getInputStream(HttpsURLConnectionImpl.java:254)
at personal.Project.GetUrl.getReq(GetUrl.java:25)
at personal.Project.GetUrl.main(GetUrl.java:34)

我尝试了以下页面但没有成功:

+Received fatal alert: handshake_failure through SSLHandshakeException

+How to solve javax.net.ssl.SSLHandshakeException Error?

这是我的代码:

package personal.Project;

    import java.io.IOException;

    import java.io.InputStream;

    import java.net.MalformedURLException;

    import java.net.URL;

    import java.net.URLConnection;

    import java.net.URLEncoder;

    public class GetUrl {

        private String url = "https://www.sunnyportal.com/Templates/ChartValues.aspx";

private String charset = "UTF-8";  // Or in Java 7 and later, use the constant: java.nio.charset.StandardCharsets.UTF_8.name()
private String login = "<>";
private String password = "<>";

public String getReq() throws MalformedURLException, IOException
{
    String query = String.format("login=%s&password=%s", 

            URLEncoder.encode(login, charset), 
            URLEncoder.encode(password, charset));

        URLConnection c = new URL(url + "?" + query).openConnection();
        c.setRequestProperty("Accept-Charset", charset);
        InputStream response = c.getInputStream();  

        return response.toString();
}
public static void main (String args[])
{
    GetUrl data = new GetUrl();
    String getString = null;
    try {
        getString = data.getReq();
    } catch (IOException e) {
        // TODO Auto-generated catch block
        e.printStackTrace();
        System.exit(1);
    }

    System.out.println( getString );
}

}

很想帮助解决这个问题,提前致谢!

根据 https://www.ssllabs.com/ssltest/analyze.html?d=sunnyportal.com,服务器仅协商一个密码套件 TLS_RSA_WITH_AES_256_CBC_SHA,它使用 AES 和 256 位密钥。

如果您使用 Oracle Java 来使用 128 位以上的任何对称密码,包括 AES 256,您必须 下载并安装JCE Unlimited Strength 适用于您的版本的管辖策略文件。对于当前支持的版本,8,靠近通用下载页面底部 http://www.oracle.com/technetwork/java/javase/downloads/index.html it links to http://www.oracle.com/technetwork/java/javase/downloads/jce8-download-2133166.html . For older versions search finds http://www.oracle.com/technetwork/java/javase/downloads/jce-7-download-432124.html and http://www.oracle.com/technetwork/java/javase/downloads/jce-6-download-429243.html .

PS: 的骗局,虽然我不确定你是否能找到它。