小编and*_*iri的帖子

Android webview获取sslError SSL_UNTRUSTED但证书有效

onReceivedSslError在我的WebViewClient中实现了一个方法来正确处理webview中的无效https证书:

@Override
        public void onReceivedSslError(WebView view, final SslErrorHandler handler, SslError error) {
            final AlertDialog.Builder builder = new AlertDialog.Builder(WebActivity.this);
            String message = "SSL Certificate error.";
            switch (error.getPrimaryError()) {
                case SslError.SSL_UNTRUSTED:
                    message = "The certificate authority is not trusted.";
                    return;
                case SslError.SSL_EXPIRED:
                    message = "The certificate has expired.";
                    break;
                case SslError.SSL_IDMISMATCH:
                    message = "The certificate Hostname mismatch.";
                    break;
                case SslError.SSL_NOTYETVALID:
                    message = "The certificate is not yet valid.";
                    break;
            }
            message += " Do you want to continue anyway?";

            builder.setTitle("SSL …
Run Code Online (Sandbox Code Playgroud)

ssl https android webview webviewclient

7
推荐指数
2
解决办法
1955
查看次数

标签 统计

android ×1

https ×1

ssl ×1

webview ×1

webviewclient ×1