webview握手失败

Udi*_*ghe 3 android android-webview

我无法使用 webview 调用发布请求 (Https)。在我的 logcat 中,我找到了这个

[1031/175452:ERROR:ssl_client_socket_openssl.cc(905)] 握手失败;返回 0,SSL 错误代码 5,net_error -107****

它在 android 4.3 中不起作用

Daw*_*ham 8

快速修复:忽略 SSL 证书错误。

    WebView webview = findViewById(R.id.webView_about_alc);


    webview.setWebViewClient(new WebViewClient() {

        @Override
        public void onReceivedError(WebView view, int errorCode, String description, String failingUrl) {
            Toast.makeText(AboutAlcActivity.this, description, Toast.LENGTH_SHORT).show();
        }

        @Override
        public void onReceivedSslError(WebView view, SslErrorHandler handler, SslError er) {
            handler.proceed(); // Ignore SSL certificate errors
        }

    });

    webview.loadUrl(ALC_ABOUT_PAGE);
Run Code Online (Sandbox Code Playgroud)

——

更好的解决方案: 修复项目的 Android 网络安全配置。请按照以下链接了解如何操作。

https://developer.android.com/training/articles/security-config