使用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 ...
最新文章
- InitializeComponent()有什么作用?
- 掌握 Ajax,第 8 部分: 在请求和响应中使用 XML
- python文件读取模式_day-2 python 文件读写模式r,r+,w,w+,a,a+的区别
- android 6.0版本名字,棉花糖Marshmallow 是Android 6.0的名字
- Oracle 数据库-分组函数总结
- mysql 语句 集锦_mysql 语句集锦
- Conda solving environment一晚上还不能完成有解吗?
- Linux下监视NVIDIA的GPU使用情况
- IOS学习笔记07---C语言函数-printf函数
- Access数据库基于时间盲注的实现[www.freebuf.com]
- [转载]MySQL exists的用法介绍
- Mac端Java开发分析工具JProfiler 13.0.1
- Java for LeetCode 231 Power of Two
- PLC的编程与应用学习笔记
- 在centos系统上安装python
- 谷歌广告已拒登:恶意软件或垃圾软件 如何解决
- 塔顶放大器在移动通信网中的作用
- vin端口是什么意思_路由器的指示灯一般代表什么意思,各个灯有什么含义
- Qt [GC9-14]:HUD-定速巡航、自适应巡航、车道偏离、车距保持
- 默纳克调试说明书_默纳克NICE调试说明书修改版
热门文章
- SuperMap iDesktop 8C 空间数据处理与管理
- Docker部署爬虫实战
- [Swift]LeetCode741. 摘樱桃 | Cherry Pickup
- 计算机教师面试1分钟自我介绍视频,音乐教师面试1分钟自我介绍4篇
- Linux上JMeter使用IP欺骗
- 美图发力社交行业 用户需求驱动社交化转型
- 【实用】JAVA通过URL链接获取视频文件信息(无需下载文件)
- 计算机原理董洁答案,微计算机原理
- 华邦存储器W25Q80, W25Q16, W25Q32系列的spi通讯
- 2055. Plates Between Candles