在java 1.6版本中,通过HttpsURLConnection请求class 1(多发生于免费ssl证书,比如沃通或者startssl的)的https网络地址时,可能会报握手异常:

Caused by: java.lang.RuntimeException: javax.net.ssl.SSLHandshakeException: Received fatal alert: handshake_failure
- Received fatal alert: handshake_failure
javax.net.ssl.SSLHandshakeException: Received fatal alert: handshake_failure
at com.sun.net.ssl.internal.ssl.Alerts.getSSLException(Alerts.java:)
at com.sun.net.ssl.internal.ssl.Alerts.getSSLException(Alerts.java:)
at com.sun.net.ssl.internal.ssl.SSLSocketImpl.recvAlert(SSLSocketImpl.java:)
at com.sun.net.ssl.internal.ssl.SSLSocketImpl.readRecord(SSLSocketImpl.java:)
at com.sun.net.ssl.internal.ssl.SSLSocketImpl.performInitialHandshake(SSLSocketImpl.java:)
at com.sun.net.ssl.internal.ssl.SSLSocketImpl.startHandshake(SSLSocketImpl.java:)
at com.sun.net.ssl.internal.ssl.SSLSocketImpl.startHandshake(SSLSocketImpl.java:)
at sun.net.www.protocol.https.HttpsClient.afterConnect(HttpsClient.java:)
at sun.net.www.protocol.https.AbstractDelegateHttpsURLConnection.connect(AbstractDelegateHttpsURLConnection.java:)
at sun.net.www.protocol.http.HttpURLConnection.getInputStream(HttpURLConnection.java:)
at sun.net.www.protocol.https.HttpsURLConnectionImpl.getInputStream(HttpsURLConnectionImpl.java:)

可以做如下尝试:

    /*
* 在java1.6中,进行https的请求会提示 Received fatal alert: handshake_failure
* 的握手失败的异常,网上的资料说这是个bug
* 参考此贴http://www.coderanch.com/t/637177/Security/Disabling-handshake-message-Java 按照楼主处理, 把协议版本临时修改,再恢复的方式绕过了此bug
*/
String defaultValue = System.getProperty("https.protocols");
System.setProperty("https.protocols", "TLSv1");
String response = CommonUtils.getResponseFromServer(url, "utf-8");//请求https地址
log.debug("用户登陆过程正常:获得响应为" + response); if (defaultValue != null) {
System.setProperty("https.protocols", defaultValue);
} else {
System.clearProperty("https.protocols");
}

handshake_failure的更多相关文章

  1. (转)解决jdk1.8中发送邮件失败(handshake_failure)问题

    解决jdk1.8中发送邮件失败(handshake_failure)问题 作者 zhisheng_tian 2016.08.12 22:44* 字数 1573 阅读 2818评论 6喜欢 9 暑假在家 ...

  2. Eclipse4.6安装Tomcat插件时报错:Unable to read repository at http://tomcatplugin.sf.net/update/content.xml. Received fatal alert: handshake_failure

    错误如下: Unable to read repository at http://tomcatplugin.sf.net/update/content.xml.Received fatal aler ...

  3. 解决idea gradle构建Received fatal alert: handshake_failure问题

    Gradle是一款强大的构建工具,但是搭建项目运行环境总是非常头痛,各种网络原因会导致项目不能成功的导入. 说一下这个问题的解决办法,折腾了很久终于解决了. javax.net.ssl.SSLHand ...

  4. jdk1.7访问https报javax.net.ssl.SSLHandshakeException: Received fatal alert: handshake_failure问题解决

    本地jdk版本java version "1.8.0_31",代码中已对https做了相应处理:信任所有来源证书,运行正常:上包到服务器(服务器jdk版本java version ...

  5. 转:javax.net.ssl.SSLHandshakeException: Received fatal alert: handshake_failure 解决方案

    转:javax.net.ssl.SSLHandshakeException: Received fatal alert: handshake_failure 解决方案javax.net.ssl.SSL ...

  6. java mail Received fatal alert: handshake_failure java 无法发送邮件问题 java 发送qq邮件(含源码)

     java 无法发送邮件问题 java 发送qq邮件 报错:java mail Received fatal alert: handshake_failure (使用ssl) javax.mail.M ...

  7. 处理Https 异常记录 javax.net.ssl.SSLHandshakeException: Received fatal alert: handshake_failure

    http://blog.csdn.net/baidu_18607183/article/details/51595330 https://blogs.oracle.com/java-platform- ...

  8. javax.net.ssl.SSLHandshakeException: Received fatal alert: handshake_failure

    SSL握手失败:用JDK1.8做发邮件的功能遇到这种问题处理方式是:将目录 %JAVA_HOME%\...\jre\lib\security里的local_policy.jar,US_export_p ...

  9. javax.net.ssl.SSLHandshakeException: Received fatal alert: handshake_failure 解决方案

    这个是jdk导致的,jdk里面有一个jce的包,安全性机制导致的访问https会报错,官网上有替代的jar包,换掉就好了 目录 %JAVA_HOME%\jre\lib\security里的local_ ...

随机推荐

  1. Ubuntu 14.10下搭建简易FTP服务器[vsftpd]

    Ubuntu下公认最易上手的ftp软件是vsftpd,既然标题都说了是“简易”的,那么必然是用最大众的..下面是正题 目标需求:搭建一个允许匿名/本地登录的FTP,并且支持上传/下载/修改功能,同时F ...

  2. echo, print, print_r

    echo 不是函数,没有返回值,因此只是用作输出的话会更快 print 和 print_r 有返回值,区别在于: print 用于打印一个字符串,print_r 可以打印一些复合类型,如: $arr= ...

  3. MySQL语句中的转义字符----引号

    MySQL语言中的转义字符和各种编程语言基本相同,见下表 形式 含义 \0 0(NUL)字符 \n 换行 \r 回车符 \t 制表符 \b 退格 \' 单引号 \" 双引号 \\ 反斜线 \ ...

  4. mov和ldr/str的区别

    ARM是RISC结构,数据从内存到CPU之间的移动只能通过L/S指令来完成,也就是ldr/str指令.比如想把数据从内存中某处读取到寄存器中,只能使用ldr比如:ldr r0, 0x12345678就 ...

  5. codeforces 732D(二分)

    题目链接:http://codeforces.com/contest/732/problem/D 题意:有m门需要过的课程,n天的时间可以选择复习.考试(如果的d[i]为0则只能复习),一门课至少要复 ...

  6. jQuery:cookie插件的使用

    Jquery插件就是在Jquery基础之上,开发的基于Jquery的javascript库. 在Jquery中,引入cookie插件后,可以很方便的定义某个cookie的名称,并设置cookie值.通 ...

  7. css技巧收集

    1. 使用 :not() 为导航添加/取消边框 传统的方法为导航栏添加边框: /* add border */ .nav li { border-right: 1px solid #666; } /* ...

  8. Vim速查脑图

  9. java可变参数

    Java1.5增加了新特性:可变参数:适用于参数个数不确定,类型确定的情况,java把可变参数当做数组处理.注意:可变参数必须位于最后一项.当可变参数个数多余一个时,必将有一个不是最后一项,所以只支持 ...

  10. php + sqlserver

    Dbconn <?php class DbConn{ private $conn; private $rs; private function __construct(){ $serverNam ...