场景
使用WebView加载某一网址时,不能正常显示网页,在Logcat出现以下错误提示。
I/X509Util: Failed to validate the certificate chain, error: java.security.cert.CertPathValidatorException: Trust anchor for certification path not found.
解决方案
webView.setWebViewClient(new WebViewClient() {
@Override
public void onReceivedSslError(WebView view, SslErrorHandler handler, SslError error) {
//千万不能调用super的方法,super方法中默认取消了处理
//super.onReceivedSslError(view, handler, error);
handler.proceed();
}
});
WebView SSL错误解决
本文介绍了一个WebView加载特定网址时遇到的SSL证书验证错误,并提供了一种解决方案:通过覆写onReceivedSslError方法并调用handler.proceed()来忽略证书验证问题。
1501

被折叠的 条评论
为什么被折叠?



