Java笔记-解决SSLHandshakeException: No subject alternative names present
我这边是这样出现的问题,做了一个双向认证的WebService,证书是用keytools做的自签名,其中cn为localhost。在外网测试的时候,客户端检测自己的证书不通过。百度没有找到决解的办法,最后去外网看了,用了洋人的方法解决的。在此记录下。
在自己的代码中,需要连接网络的地方添加如下静态函数:
static {HttpsURLConnection.setDefaultHostnameVerifier(new HostnameVerifier(){public boolean verify(String hostname, SSLSession session){// ip address of the service URL(like.23.28.244.244)if (hostname.equals("23.28.244.244"))return true;return false;}});
}
如果是java8可以用下面的表现方式:
static {HttpsURLConnection.setDefaultHostnameVerifier((hostname, session) -> hostname.equals("127.0.0.1"));
}
本人在项目里面是这样操作的:
Java笔记-解决SSLHandshakeException: No subject alternative names present相关推荐
- JDK安全证书的一个错误消息 No subject alternative names present的解决办法
我使用Java消费某网站一个Restful API时,遇到这个错误: 21:31:16.383 [main] DEBUG org.springframework.web.client.RestTemp ...
- No subject alternative names present solved
这个异常有可能是SAN (Subject alternative name) 与CN (Common Name)没设置好引起. 网上翻阅了许多资料,下面记录一下解决的方法. 1. 拿着Server 给 ...
- Certificate doesn't match any of the subject alternative names问题的解决
用HttpClient发送HTTPS请求报SSLException: Certificate for <域名> doesn't match any of the subject alter ...
- Certificate for <xx.xxx.xxx.xxx> doesn‘t match any of the subject alternative names: [xx.xxxx.xxxx.
1. 用HttpClient发送Https请求报SSLException: Certificate for <域名> doesn't match any of the subject al ...
- Certificate for <xxx.xxx.xxx.com> doesn‘t match any of the subject alternative names: [xxx..com]
问题和解决 我这里先描述问题和解决方案吧.很多同学不太关心发生的背景. 问题表象 Certificate for <xxx.xxx.xxx.com> doesn't match any o ...
- Certificate for doesn't match any of the subject alternative names: [.xxx.id, .yyy.id, mmm.id]
强烈推荐一个大神的人工智能的教程:http://www.captainbed.net/zhanghan [前言] 最近在调用第三方测试环境的时候日志中报Certificate for doesn't ...
- Java笔记-解决WebServiceTemplate中No subject alternative names matching IP address xxx
主要的原因是证书有问题,就是程序的IP地址和证书的IP地址不匹配. 这里是客户端报错,使用的是spring-ws 对应的Maven如下: <dependency><groupId&g ...
- Java笔记-解决读取文件时中文乱码问题(InputStreamReader设置编码)
Java一般读取文件时使用如下代码: InputStream inputStream = this.getClass().getClassLoader().getResourceAsStream(&q ...
- Java笔记-解决Cause: java.sql.SQLException: 试图在只读事务中修改数据(达梦数据库)
解决方法: @Transactional(readOnly=false) 这里要注意,可能会失效,一定要放对位置. 要包住所有sql调用的函数的上面,不要只包一部分,不然不会生效的.
最新文章
- LVS+DR源码安装
- 定西市计算机考试,2019年3月甘肃省定西市计算机等级考试时间
- 计算机应用计算机电算化题库,2014年浙江省会计电算化客观题题库
- AdaX:一个比Adam更优秀,带”长期记忆“的优化器
- Java8 Stream详解~排序:sorted
- windows7未能启动怎么修复计算机,win7系统提示windows无法启动这个硬件设备怎么办...
- P5725 【深基4.习8】求三角形(python3实现)
- 退出所有循环_Python学习之路9—循环的总结
- spring cloud + spring boot + springmvc+mybatis分布式微服务云架构
- inotify和epoll
- java文件改成smla,Java base64 转 FileInputStream
- python基础数据类型语法
- 【Arduino】开发入门【八】舵机操作+源代码
- 记录下帮助一位网友解决的关于android子控件的onTouch或onClick和父OnTouch 冲突的问题。
- php如何做支付,php实现银联支付
- 互联网信息安全与加密技术
- 主编编辑器如何设置我的签名?
- mysql drop语句怎么用_SQL DROP 语句
- java毕业生设计中小型连锁超市配送中心配送管理计算机源码+系统+mysql+调试部署+lw
- 学习笔记:SpringCloud 微服务技术栈_实用篇②_黑马旅游案例