Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/ssl/3.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Android 如何使WebView在每次重新加载页面时显示SSL错误?_Android_Ssl_Webview - Fatal编程技术网

Android 如何使WebView在每次重新加载页面时显示SSL错误?

Android 如何使WebView在每次重新加载页面时显示SSL错误?,android,ssl,webview,Android,Ssl,Webview,我的webview应用程序收到SSL错误。它会显示一条警告消息,询问是否加载网站。单击yes按钮,它将忽略SSL错误来加载网站。但是,当我重新加载同一个网站时,它不会向我显示处理错误的警告消息,而是直接加载该网站 因此,我的问题是如何使webview在每次我重新加载网站时向我显示处理SSL错误的警告消息? 我处理ssl错误的代码是`` if(error.getPrimaryError()==SslError.SSL_UNTRUSTED)

我的webview应用程序收到SSL错误。它会显示一条警告消息,询问是否加载网站。单击yes按钮,它将忽略SSL错误来加载网站。但是,当我重新加载同一个网站时,它不会向我显示处理错误的警告消息,而是直接加载该网站

因此,我的问题是如何使webview在每次我重新加载网站时向我显示处理SSL错误的警告消息?

我处理ssl错误的代码是``

                    if(error.getPrimaryError()==SslError.SSL_UNTRUSTED)
                    {

                        final Dialog sslalertdialog = new Dialog(browser.this);
                        sslalertdialog.setContentView(R.layout.sslerroralert);
                        sslalertdialog.show();
                        TextView sslalertmessage, sslalerttitle;
                        Button yes,no;
                        sslalertmessage= (TextView) sslalertdialog.findViewById(R.id.sslerrormessage);
                        sslalerttitle= (TextView) sslalertdialog.findViewById(R.id.sslerrorTitle);
                        String  message="The Website Security Certificate is Not Trusted." +
                                "One possible cause of this error is that a self-signed certificate is installed on the Website's server. " +
                                "Self-signed certificates aren't trusted by browsers because they are generated by Website's server, not by an accredited Certificate Authority (CA)." +
                                "Another cause of the error is that Someone is trying to intercept your communication." +
                                "You Should not Proceed,if you have never seen this error message for this Website before." +
                                "And if you want to proceed ,plz donot provide any sensitive Infomation to the site (like Credit Card Details " +
                                "Do you want to proceed anyways ?";
                        sslalerttitle.setText("The Website Cannot be Trusted!");
                        sslalertmessage.setText(message);
                        no=(Button) sslalertdialog.findViewById(R.id.NOBUTTON);
                        yes=(Button) sslalertdialog.findViewById(R.id.YES_BUTTON);
                        no.setOnClickListener(new View.OnClickListener() {
                            @Override
                            public void onClick(View v) {
                                sslalertdialog.dismiss();
                                handler.cancel();
                            }
                        });
                        yes.setOnClickListener(new View.OnClickListener() {
                            @Override
                            public void onClick(View v) {
                                sslalertdialog.dismiss();
                                handler.proceed();

                                padlock.setImageDrawable(getDrawable(R.drawable.ic_warning_red_400_24dp));

                            }
                        });

您可以使用WebView的ClearSLPreferences()函数,如:

webView.clearSslPreferences()

它将清除您对此WebView对象的决定,您可能会再次收到警告消息。

您可以使用WebView的ClearSLPreferences()函数,如:

webView.clearSslPreferences()

这将清除您对WebView对象的决定,您可能会再次收到警告消息。

关于这一点有什么消息吗?我遇到了同一个问题,每次都需要显示一个对话框。关于这个有什么新闻吗?我遇到了同样的问题,每次都需要显示一个对话框。