我这边是这样出现的问题,做了一个双向认证的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相关推荐

  1. JDK安全证书的一个错误消息 No subject alternative names present的解决办法

    我使用Java消费某网站一个Restful API时,遇到这个错误: 21:31:16.383 [main] DEBUG org.springframework.web.client.RestTemp ...

  2. No subject alternative names present solved

    这个异常有可能是SAN (Subject alternative name) 与CN (Common Name)没设置好引起. 网上翻阅了许多资料,下面记录一下解决的方法. 1. 拿着Server 给 ...

  3. Certificate doesn't match any of the subject alternative names问题的解决

    用HttpClient发送HTTPS请求报SSLException: Certificate for <域名> doesn't match any of the subject alter ...

  4. 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 ...

  5. 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 ...

  6. 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 ...

  7. Java笔记-解决WebServiceTemplate中No subject alternative names matching IP address xxx

    主要的原因是证书有问题,就是程序的IP地址和证书的IP地址不匹配. 这里是客户端报错,使用的是spring-ws 对应的Maven如下: <dependency><groupId&g ...

  8. Java笔记-解决读取文件时中文乱码问题(InputStreamReader设置编码)

    Java一般读取文件时使用如下代码: InputStream inputStream = this.getClass().getClassLoader().getResourceAsStream(&q ...

  9. Java笔记-解决Cause: java.sql.SQLException: 试图在只读事务中修改数据(达梦数据库)

    解决方法: @Transactional(readOnly=false) 这里要注意,可能会失效,一定要放对位置. 要包住所有sql调用的函数的上面,不要只包一部分,不然不会生效的.

最新文章

  1. LVS+DR源码安装
  2. 定西市计算机考试,2019年3月甘肃省定西市计算机等级考试时间
  3. 计算机应用计算机电算化题库,2014年浙江省会计电算化客观题题库
  4. AdaX:一个比Adam更优秀,带”长期记忆“的优化器
  5. Java8 Stream详解~排序:sorted
  6. windows7未能启动怎么修复计算机,win7系统提示windows无法启动这个硬件设备怎么办...
  7. P5725 【深基4.习8】求三角形(python3实现)
  8. 退出所有循环_Python学习之路9—循环的总结
  9. spring cloud + spring boot + springmvc+mybatis分布式微服务云架构
  10. inotify和epoll
  11. java文件改成smla,Java base64 转 FileInputStream
  12. python基础数据类型语法
  13. 【Arduino】开发入门【八】舵机操作+源代码
  14. 记录下帮助一位网友解决的关于android子控件的onTouch或onClick和父OnTouch 冲突的问题。
  15. php如何做支付,php实现银联支付
  16. 互联网信息安全与加密技术
  17. 主编编辑器如何设置我的签名?
  18. mysql drop语句怎么用_SQL DROP 语句
  19. java毕业生设计中小型连锁超市配送中心配送管理计算机源码+系统+mysql+调试部署+lw
  20. 学习笔记:SpringCloud 微服务技术栈_实用篇②_黑马旅游案例

热门文章

  1. VC多线程编程之线程创建与示例
  2. 如何在CISCO PIX上实现×××步骤?
  3. JavaScript中substr和substring
  4. 面试问“请介绍下自己”,应聘者就回了两点,立马勾起HR的兴趣!
  5. 5招训练你的数据敏感度,数据高手都在用
  6. 用好这个新功能,报表数据安全瞬间提升一个等级!
  7. 这个是什么单机经典模式的引入
  8. 那些开发《虚拟光驱》的人们
  9. 你敢面对这样的现实吗?
  10. 5分钟 0元搭建个人独立博客网站(一)