Monodroid WebView Loading SSL page

你离开我真会死。 提交于 2021-01-28 21:48:47

问题


I have tried loading a WebView with a SSL page, and I am getting an error. Code and error below. I have set my permissions to allow Internet access.

I think this is a Mono-only issue. When I try my SSL web page in the default browser it works fine.

WebView webView = new WebView(this);
string website = "https://...";
webView.Settings.JavaScriptEnabled = true;
webView.SetWebViewClient(new WebViewClientAuthentication());
webView.LoadUrl(website);

//definition for WebViewClientAuthentication
public class WebViewClientAuthentication : WebViewClient
{
    public override void OnReceivedSslError(WebView view, SslErrorHandler handler, Android.Net.Http.SslError error)
    {
        Log.Error("SSL ERROR",string.Format("SSL ERROR: {0}, Primary: {1}", error.GetType.ToString(), error.PrimaryError.ToString()));
        base.OnReceivedSslError(view, handler, error);
    }
}

OUTPUT SSL ERROR: Android.Net.Http.SslError, Primary: Notyetvalid

COMMENTS I have seen this message: http://mono-for-android.1047100.n5.nabble.com/SSL-issues-td5629485.html - but I am not sure what it means in terms of loading SSL sites into a webview.


回答1:


Try this:

//definition for WebViewClientAuthentication
public class WebViewClientAuthentication : WebViewClient
{
    public override void OnReceivedSslError(WebView view, SslErrorHandler handler, Android.Net.Http.SslError error)
    {
        handler.Proceed();
    }
}


来源:https://stackoverflow.com/questions/12034452/monodroid-webview-loading-ssl-page

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