使用Java访问https接口javax.net.ssl.SSLHandshakeException: Received fatal alert: handshake_failure
使用Java访问https://**************** 接口 控制台提示握手失败错误;javax.net.ssl.SSLHandshakeException: Received fatal alert: handshake_failure
1.jdk版本问题,换用jdk1.7;
2.如不能更换jdk版本,引入 bcprov-jdk15on-157.jar 此jar包对jdk1.5-1.8都可支持;public static String httpsRequsetForTLSv12(String host, String url) throws Exception {java.security.SecureRandom secureRandom = new java.security.SecureRandom();Socket socket = new Socket(java.net.InetAddress.getByName(host), 443);TlsClientProtocol protocol = new TlsClientProtocol(socket.getInputStream(), socket.getOutputStream(),secureRandom);DefaultTlsClient client = new DefaultTlsClient() {public TlsAuthentication getAuthentication() throws IOException {TlsAuthentication auth = new TlsAuthentication() {public void notifyServerCertificate(org.bouncycastle.crypto.tls.Certificate serverCertificate) throws IOException {}public TlsCredentials getClientCredentials(CertificateRequest certificateRequest) throws IOException {return null;}};return auth;}};protocol.connect(client);java.io.OutputStream output = protocol.getOutputStream();output.write(("GET "+url+" HTTP/1.1\r\n").getBytes("UTF-8"));output.write(("Host: "+host+"\r\n").getBytes("UTF-8"));output.write("Connection: close\r\n".getBytes("UTF-8")); output.write("\r\n".getBytes("UTF-8")); output.flush();java.io.InputStream input = protocol.getInputStream();BufferedReader reader = new BufferedReader(new InputStreamReader(input, "UTF-8"));String line;String result = null;while ((line = reader.readLine()) != null){result = line;//System.out.println(line);}return result;}
使用Java访问https接口javax.net.ssl.SSLHandshakeException: Received fatal alert: handshake_failure相关推荐
- SoapUI 请求 https 报 javax.net.ssl.SSLHandshakeException: Received fatal alert: handshake_failure
SoapUI 请求 https 报 javax.net.ssl.SSLHandshakeException: Received fatal alert: handshake_failure 在 E:\ ...
- 解决javax.net.ssl.SSLHandshakeException: Received fatal alert: handshake_failure报错
背景 java版本1.8.0,今天尝试用Java去访问一个https接口,但抛出下面的异常: javax.net.ssl.SSLHandshakeException: Received fatal a ...
- javax.net.ssl.SSLHandshakeException: Received fatal alert: handshake_failure问题解决
最近在生产环境调用Https接口出现这个问题javax.net.ssl.SSLHandshakeException: Received fatal alert: handshake_failure,经 ...
- javax.net.ssl.SSLHandshakeException: Received fatal alert: handshake_failure
问题描述:在jdk1.7环境中使用HttpURLConnection发送https请求时,异常了 javax.net.ssl.SSLHandshakeException: Received fatal ...
- 搞定 javax.net.ssl.SSLHandshakeException: Received fatal alert: handshake_failure 问题!
开始碰到这个问题找遍了各种方法,其实还是需要耐心的先搞清楚原因再想方法靠谱,这里也总结下这个异常的多种解决方案, 首先先理解下为什么出现handshake?字面理解是客户端与服务端握手失败,能导致握手 ...
- 访问https,抛出的异常javax.net.ssl.SSLHandshakeException: Received fatal alert: handshake_failure
话说这个坑有点深,查阅大半个百度几乎没解决 部分网友解释:是因为jdk中jce的安全机制导致报的错,按照大家的方式,要去oracle官网下载对应的jce包替换jdk中的jce包. jce所在地址: % ...
- javax.net.ssl.SSLHandshakeException: Received fatal alert: certificate_unknown
安装完Azkaban后web页面访问时无法跳转登录页面,显示: 点击高级后没有继续访问的选项,查看 azkaban-web 服务报错如下: 随后检查了ssl证书没问题,分析可得Mac系统需要对自己生成 ...
- javax.net.ssl.SSLException: Received fatal alert: protocol_version问题解决
本来以为这个问题百度一大堆肯定很好解决,没想到还是卡了一会儿. 网上的方案和我自己的情况不完全匹配,所以记录下来. 完整报错如下: com.mysql.jdbc.exceptions.jdbc4.Co ...
- Could not transfer artifact (https://repo.maven.apache.org/maven2): Received fatal alert: protocol_v
异常信息 Failed to read artifact descriptor for org.slf4j:slf4j-api:jar:1.7.2 org.eclipse.aether.resolut ...
最新文章
- 乐嘉性格色彩分析测试题
- 开发者转型AI看过来,这是一场汇聚中美顶尖专家的AI盛会
- 霸榜COCO和Cityscapes!南理工CMU提出极化自注意力,更精细的双重注意力建模结构
- 一、【用django2.0来开发】 环境部署和初始化项目
- java中10个用户注册_JavaWeb(十)Session
- Windows server 2008 r2搭建FTP服务器
- TMS320C55x的寄存器
- 老李分享: 全栈工程师? 2
- DevOps使用教程 华为云(7)团队绩效评估 工时统计
- 十次方项目登陆问题 token令牌解析,claims获取不到userid,求大神帮忙看下代码解决问题
- win10此电脑不见了_Win10如何把控制面板放到桌面上?Win10控制面板不见了解决方法...
- 将一个Vue项目跑起来
- win10锁屏界面无法更换图片(亲测有效)
- 测试环境Hosts设置
- 2020双十一商家物流迎来大考:看拙燕仓如何破局?
- 关于C#建立FLASH服务端的安全沙箱问题
- Android中的通知Notification
- 智解京东618——购物狂欢背后的安全暗战
- 为什么husky哈士奇放弃了传统的 JS 配置(翻译)
- workflow工作流(二):34张表