C# – Is it possible to use ServicePointManager with Webbrowser control

browserccertificate

I want to disable "Alert window" that I get from login page of one HTTPS site with "untrusted certificate".

ServicePointManager is used for WebRequest/WebResponse:

> public static bool
> ValidateServerCertificate(object
> sender, X509Certificate certificate,
> X509Chain chain, SslPolicyErrors
> sslPolicyErrors) {
>     return true; }
> 
> ServicePointManager.ServerCertificateValidationCallback
> = new RemoteCertificateValidationCallback(ValidateServerCertificate);

but how can I use it with Webbrowser control?

Best Answer

The ServicePointManager is for managed code; WebBrowser is a wrapper around shdocvw, so will almost certainly have a very different programming model.

if you can automate this (and I'm not sure that you can), I would expect to have to reference the COM version to get the full API (see: AxWebBrowser). WebBrowser only exposes a .NET-friendly subset of the full functionality - enough to get most common jobs done.

One other option might be to get the data yourself (WebClient / WebRequest / etc), and simply push that html into the WebBrowser - but this will mess up external links etc.