一个android/webview的BUG:ERR_EMPTY_RESPONSE

版权声明:转载请邮件联系我([email protected]),以取得授权,谢谢! https://blog.csdn.net/yeshennet/article/details/82792343

本文同步发于 nanny,nanny上的作者也是本人

最近在测试设备兼容性,然后测试的小伙伴提了一个bug:在一部vivo手机上,在打开网页的时候,会出现加载失败;网络没问题;android的原生请求能通;webview中打开的所有页面都会白屏;日志中的报错信息是:ERR_EMPTY_RESPONSE。

结论与修正方法

https证书比较小众/新,该vivo没有信任它的CA,换了一个正常点的CA就没问题了。

绕过方法

  • 不用https,把https请求换成http
  • 在网页上下载目标网址的CA证书,在手机上的“安全->受信凭据”中增加该证书

发现过程与方法

拿到手机前

当知道是这个ERR_EMPTY_RESPONSE错误之后,我查了一下资料。有几个方向。

1,手机是不是真的连不上网?手机的Host配置有没有错?

能联网。

2,是不是浏览器有脏缓存

mWebView.clearCache(true);

mContext.deleteDatabase("webview.db");
mContext.deleteDatabase("webviewCache.db");

CookieSyncManager.createInstance(this);         
CookieManager cookieManager = CookieManager.getInstance();        
cookieManager.removeAllCookie();

3,手机是不是有测过VPN之类的东西,导致域名解析出错?

MTL的小伙伴还帮忙恢复了出厂设置,还是必现

4,在手机的默认浏览器上打开是否正常?

打开是正常的。后面我借到设备,chrome、搜狗、vivo自动的浏览器都是正常的;百度的和webview中的表现一致,都是提示找不到网页。

找MTL的小伙伴调了两次,没修到问题:(。所以我…跑过去大厦接手机回来测。

拿到手机后

1,试了一下我自己的域名,可以打开,再换回去UUSDK的域名,就不行了。考虑是域名出错。

2,试着把https换成http,结果居然可以打开!

3,curl https://XXXXX.example.com

curl: (60) SSL certificate problem, verify that the CA cert is OK. Details:
error:14090086:SSL routines:SSL3_GET_SERVER_CERTIFICATE:certificate verify failed
More details here: http://curl.haxx.se/docs/sslcerts.html

curl performs SSL certificate verification by default, using a "bundle"
 of Certificate Authority (CA) public keys (CA certs). If the default
 bundle file isn't adequate, you can specify an alternate file
 using the --cacert option.
If this HTTPS server uses a certificate signed by a CA represented in
 the bundle, the certificate verification probably failed due to a
 problem with the certificate (it might be expired, or the name might
 not match the domain name in the URL).
If you'd like to turn off curl's verification of the certificate, use
 the -k (or --insecure) option.

这时候看到这个错误信息,已经很明显了。

4,把当前的证书加进系统受信凭据中再次打开,没问题了

小结

  • 这种兼容性的问题靠开发意淫真的很难 : (
  • google了半天也没半点有用信息 : (
  • 修正了问题还是很愉快的 : )
  • MTL真棒!

猜你喜欢

转载自blog.csdn.net/yeshennet/article/details/82792343