在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. 如何判断pc或者移动端

    <script type="text/javascript"> var userAgentInfo = navigator.userAgent; var Agents ...

  2. delphi里动态创建AlphaControls实现换肤

    AlphaControls是一套Delphi下的优秀的皮肤vcl控件.几年前,一般用得比较多的是vclskin,使用很方便,可惜这套2010年已经停止维护了.后来就看到更多的人开始推崇AlphaCon ...

  3. PKU 1003解题

    首先庆祝一下,今天连A了3题.感觉后面这题太简单了.. 由于英文不好 ,找了个翻译: 若将一叠卡片放在一张桌子的边缘,你能放多远?如果你有一张卡片,你最远能达到卡片长度的一半.(我们假定卡片都正放在桌 ...

  4. sshd 指定端口,指定秘钥文件

     scp -i ~/test -P22219 SRC/ root@10.2.227.76:/data/ #sshd的端口指定的是22219,  -i 指定秘钥文件   指定秘钥文件需要注意的是,需要提 ...

  5. 用js编程输出100以内所有的质数和个数(提示:一个大于1的自然数,除了1和它本身外,不能被其他自然数整除的数都是质数)

    <script type="text/javascript"> for(var i = 3; i <= 100; i ++) {//控制2-100所有的数i fo ...

  6. JXL操作Excel

    jxl是一个韩国人写的java操作excel的工具, 在开源世界中,有两套比较有影响的API可 供使用,一个是POI,一个是jExcelAPI.其中功能相对POI比较弱一点.但jExcelAPI对中文 ...

  7. 关于BT网络的一些改进

    这几天一直在研究如何改进现有的BT网络的效率,现在有了一点小小的成果 大概思路是这样的,对于一些已经拓扑结构以及节点之间延迟的网络(并不算太苛刻,对于例如数据中心的网络来说,是可以实现的), 普通的B ...

  8. LayaAir引擎——(五)

    LayaAir引擎——关于地图详解 所需要的软件: LayaAirIDE1.0.2版本 在LayaAir引擎中与地图相关的类: 1.laya.map.TiledMap TiledMap类   地图以层 ...

  9. Android HandlerThread 的使用及其Demo (转)

    转自http://www.cnblogs.com/hnrainll/p/3597246.html 介绍 首先我们来看看为什么我们要使用HandlerThread?在我们的应用程序当中为了实现同时完成多 ...

  10. 如何使用花生壳 发布WCF服务 进行外网访问

    当我们发布WCF服务的时候,可以直接通过服务器的域名或者IP进行. 但是如果仅仅是通过花生壳进行域名解析,需要我们自己在设置的时候注意以下几点, 直接用图说明问题 1.首先配置花生壳,在红色处填写一个 ...