Quintin B
Quintin B

Reputation: 5881

Monodroid WebView Loading SSL page

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.

Upvotes: 1

Views: 4876

Answers (1)

Jim G.
Jim G.

Reputation: 15363

Try this:

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

Upvotes: 2

Related Questions