Android 异常:javax.net.ssl.SSLException: hostname in certificate didn't match
2017-09-18 15:06
886 查看
前几天我们服务器从腾讯云转到阿里云,然后部分手机厂商(主要是OPPO和VIVO)的app无法登录,经过断点测试发现app请求报错:
javax.net.ssl.SSLException: hostname in certificate didn't match ***
app用的第三方联网框架AsyncHttpClient,服务器是Https请求的,app本地并没有做ssl验证,请求响应也没问题。不知道为何域名更换服务器IP地址后部分手机就无法正常访问了,问题非常蹊跷。如果是SSL验证问题,那么之前测试肯定无法返回数据,而且应当是所有手机报错的,但是现在只有部分手机请求有问题并报错。
解决方法:
在请求之前加一句话
SSLSocketFactory.getSocketFactory().setHostnameVerifier(newAllowAllHostnameVerifier());
javax.net.ssl.SSLException: hostname in certificate didn't match ***
app用的第三方联网框架AsyncHttpClient,服务器是Https请求的,app本地并没有做ssl验证,请求响应也没问题。不知道为何域名更换服务器IP地址后部分手机就无法正常访问了,问题非常蹊跷。如果是SSL验证问题,那么之前测试肯定无法返回数据,而且应当是所有手机报错的,但是现在只有部分手机请求有问题并报错。
解决方法:
在请求之前加一句话
SSLSocketFactory.getSocketFactory().setHostnameVerifier(newAllowAllHostnameVerifier());
相关文章推荐
- Android 链接https出现 javax.net.ssl.SSLException: hostname in certificate didn't match:
- Android 链接https出现 javax.net.ssl.SSLException: hostname in certificate didn't match:
- Android 链接https出现 javax.net.ssl.SSLException: hostname in certificate didn't match:
- Android 链接https出现 javax.net.ssl.SSLException: hostname in certificate didn't match:
- HttpClient请求https,抛出javax.net.ssl.SSLException: hostname in certificate didn't match:
- httpclient对象请求:如果报这个错:javax.net.ssl.SSLException: hostname in certificate didn't match证书不匹配的主机名
- HttpsURLConnection请求https,抛出javax.net.ssl.SSLException: hostname in certificate didn't match:
- javax.net.ssl.SSLException:hostname in certificate didn't match
- Android javax.net.ssl.SSLException: hostname in certificate didn't match...
- javax.net.ssl.SSLException: hostname in certificate didn't match证书不匹配的主机名
- javax.net.ssl.SSLException: hostname in certificate didn't match:
- 12. javax.net.ssl.SSLException: hostname in certificate didn't match证书不匹配的主机名
- javax.netssl.SSLException: hostname in certificate didn't match
- javax.net.ssl.SSLException: hostname in certificate didn't match:
- android SDK 更新出现“hostname in certificate didn't match: <dl-ssl.google.com>”解决方法
- android SDK 更新出现“hostname in certificate didn't match: <dl-ssl.google.com>”解决方法
- wget 无法建立ssl连接 [ERROR: certificate common name ?..ssl.fastly.net?.doesn?. match requested host name ?.ache.ruby-lang.org?. To connect to cache.ruby-lang.org insecurely, use ?.-no-check-certificate?]
- Maven 报错:hostname in certificate didn’t match 的解决方法
- Android ksoap 访问https SSL Webservice报错 javax.net.ssl.SSLException: Not trusted server certificate