jsoup访问https网址异常SSLHandshakeException
icomment项目中有一个获取指定url页面的编码格式的方法,jsoup版本jsoup-1.8.1.jar。当jdk1.8时获取没有问题,今天将jdk版本改为1.6获取失败。
异常信息:
1 | javax.net.ssl.SSLHandshakeException: java.security.cert.CertificateException: No subject alternative DNS name matching mobile.pconline.com.cn found. |
解决方法:
- 升级jsoup版本 1.9.x
- 设置不验证SSL.validateTLSCertificates(false)
代码示例:
1 | package cn.pconline.activity.util; |
—- 2019年7月15日22:16:37
补充:在和同事联测时发现了一个神奇的现象。
- 这样的时候没有问题
- 这样就有问题
这样更加佐证了1.6编译存在问题,具体原因还说不清楚。
参考链接:
https://www.jianshu.com/p/cd43ce78d34c
https://blog.csdn.net/phone13144830339/article/details/80332851
http://landcareweb.com/questions/22250/ru-he-shi-yong-jsouptong-guo-httpslian-jie