1

I'm doing a very small app that has to display some web page(like a "kiosk"). Some of the pages that I've are only accessible in HTTPS but don't have a valid SSL certificate.

Is there a way to force the WPF WebBrowser control to allow any SSL certificate?

Something like:

<Grid>
    <WebBrowser helpers:WebBrowserUtility.BindableSource="{Binding UrlToDisplay}" AllowInvalidSSL="true"></WebBrowser>
</Grid>

If not, can you think to an alternative?

J4N
  • 19,480
  • 39
  • 187
  • 340
  • Have you tried to reconfigure system settings? I am not sure you can control this setting control-by-control, have you tried to reconfigure this on OS level? – vasek Jul 13 '17 at 06:16
  • https://stackoverflow.com/questions/178578/how-to-disable-security-alert-window-in-webbrowser-control – Vladimir Arustamian Jul 13 '17 at 06:31
  • `WebBrowser` is very thin wrapper around native controls, so you will have hard time trying to modify this behavior on WebBrowser control level. In any case - just fix the problem instead of searching for workarounds. For example install target certificate to local machine to make it trusted. – Evk Jul 13 '17 at 06:48
  • @vasek: No, since the goal is to be able to publish this without having to manage things on the environment side. – J4N Jul 13 '17 at 08:33
  • @Evk: I know but it's not an option. Or at least if something should be done(like install target certificate) this should be done by the application. – J4N Jul 13 '17 at 08:35
  • @VladimirArustamian I don't have a popup to close or anything. – J4N Jul 13 '17 at 08:36

1 Answers1

2

Not sure if you can solve it with WPF WebBrowser. However, if you use CefSharp.Wpf you can easily implement IRequestHandler and view untrusted sites without user being noticed.

bool IRequestHandler.OnCertificateError(IWebBrowser browserControl, IBrowser browser, CefErrorCode errorCode, string requestUrl, ISslInfo sslInfo, IRequestCallback callback)
{
    if (!callback.IsDisposed)
    {
        using (callback)
        {
            callback.Continue(true);
            return true;
        }
    }

    return false;
}

Taken from this example. Works perfectly for me.

vasek
  • 2,759
  • 1
  • 26
  • 30
  • I'm fully open to CefSharp.Wpf. Trying it now. How do you specify which `IRequestHandler` to use? – J4N Jul 13 '17 at 13:08
  • and more, how can you implement only this method? – J4N Jul 13 '17 at 13:21
  • @J4N You can't implement only this method, however if you just copy-paste the example above, you achieve desired funcionality. You attach the handler with `web.RequestHandler = new MyRequestHandler();` where `web` is `` in XAML. I've tested that and it works perfectly. – vasek Jul 14 '17 at 16:08