gpt4 book ai didi

java - 获取请求handshake_failure :javax.net.ssl.SSLHandshakeException

转载 作者:行者123 更新时间:2023-12-02 04:11:54 24 4
gpt4 key购买 nike

向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,该密码套件使用具有 256 位 key 的 AES。

如果您使用 Oracle Java 来使用 128 位以上的任何对称密码(包括 AES 256),则必须下载并安装 JCE Unlimited Strength 管辖策略文件你的版本。对于当前支持的版本 8,靠近通用下载页面底部 http://www.oracle.com/technetwork/java/javase/downloads/index.html它链接到http://www.oracle.com/technetwork/java/javase/downloads/jce8-download-2133166.html 。对于旧版本,搜索找到 http://www.oracle.com/technetwork/java/javase/downloads/jce-7-download-432124.htmlhttp://www.oracle.com/technetwork/java/javase/downloads/jce-6-download-429243.html .

PS:SSLHandshakeException while connecting to a https site的欺骗尽管我不确定您是否会发现这一点。

关于java - 获取请求handshake_failure :javax.net.ssl.SSLHandshakeException,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/33711010/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com