获取请求握手\u faliure:javax.net.ssl.SSLHandshakeException
向www.sunnyportal.com发送get请求时,控制台中出现错误代码,如下所示:获取请求握手\u faliure:javax.net.ssl.SSLHandshakeException,java,handshake,sslhandshakeexception,Java,Handshake,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
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)
我尝试了以下页面,但没有成功:
+
+
这是我的密码:
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 );
}
}
包个人项目;
导入java.io.IOException;
导入java.io.InputStream;
导入java.net.MalformedURLException;
导入java.net.URL;
导入java.net.URLConnection;
导入java.net.urlcoder;
公共类GetUrl{
专用字符串url=”https://www.sunnyportal.com/Templates/ChartValues.aspx";
私有字符串charset=“UTF-8”;//或者在Java 7及更高版本中,使用常量:Java.nio.charset.StandardCharsets.UTF_8.name()
私有字符串login=“”;
私有字符串密码=”;
公共字符串getReq()引发MalformedURLException,IOException
{
String query=String.format(“登录=%s和密码=%s”,
URLEncoder.encode(登录,字符集),
encode(密码,字符集));
URLConnection c=新URL(URL+“?”+查询).openConnection();
c、 setRequestProperty(“接受字符集”,字符集);
InputStream响应=c.getInputStream();
返回response.toString();
}
公共静态void main(字符串参数[])
{
GetUrl数据=新的GetUrl();
字符串getString=null;
试一试{
getString=data.getReq();
}捕获(IOE异常){
//TODO自动生成的捕捉块
e、 printStackTrace();
系统出口(1);
}
System.out.println(getString);
}
}
希望您能帮助解决这个问题,提前谢谢 根据该协议,服务器只协商一个密码套件,即TLS\U RSA\U和AES\U 256\U CBC\U SHA,后者使用AES和256位密钥
如果您使用Oracle Java使用128位以上的对称密码(包括AES 256),则必须下载并安装适用于您的版本的JCE Unlimited Strength辖区策略文件。对于当前支持的版本8,在其链接到的常规下载页面底部附近。对于旧版本,搜索将查找和
PS:dupe of虽然我不确定你是否会找到它。现在我有了这个文件,有没有某个文件夹需要我把它放进去?或者我只是启动并运行它?@PeterSparks您可以解压缩它(在现代Windows上,在资源管理器中打开可以做到这一点),然后将这两个“jar”放在JRE的
lib/security
目录中,取代“有限”目录。你的JRE在哪里变化很大,这取决于你的平台和(通常)你是如何安装它的,你没有说。zip中还有一个自述文件试图解释这一点,但仍然没有涵盖所有可能的情况。