android webview with https connection and basic auth. How to get this working?

后端 未结 3 1868
面向向阳花
面向向阳花 2021-02-02 14:31

I have researched and researched and researched this until I\'ve gone grey and bald. How on earth do I get a webview to work for a site that needs http basic authentication over

3条回答
  •  北海茫月
    2021-02-02 14:54

    It will work for https URL.In this if we are getting Untrusted_cer then we will ignore it

     webview.setWebViewClient(new WebViewClient(){
            @Override
            public void onReceivedHttpAuthRequest(WebView view,
                    HttpAuthHandler handler, String host, String realm) {
                super.onReceivedHttpAuthRequest(view, handler, host, realm);
            }
    
            @Override
            public void onReceivedSslError(WebView view,
                    SslErrorHandler handler, SslError error) {
                super.onReceivedSslError(view, handler, error);
                if(error.getPrimaryError()==SslError.SSL_UNTRUSTED){
                    handler.proceed();
                }else{
                    handler.proceed();
                }
            }
    
        });
    

    I have no idea about second problem

提交回复
热议问题