webview handshake failed

|▌冷眼眸甩不掉的悲伤 提交于 2020-08-07 20:07:09

问题


I cannot call post request (Https) using webview. In my logcat I find this

[1031/175452:ERROR:ssl_client_socket_openssl.cc(905)] handshake failed; returned 0, SSL error code 5, net_error -107****

It's not working in android 4.3


回答1:


Quick Fix: Ignore SSL certificate error.

    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);

-

Better Solution: Fix the Android Network Security Configuration for your project. Follow the below link on how to do so.

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



来源:https://stackoverflow.com/questions/47035623/webview-handshake-failed

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!