Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
776 views
in Technique[技术] by (71.8m points)

internet explorer - WebBrowser control - ignore SSL errors

Many hours of searching has not lead to an answer. We're looking for a way that a .NET WebBrowser control can navigate to pages with SSL security problems (self-signed certificates or non-matching hostnames) without stopping and displaying the error page:

http://imgur.com/Uqt7H

I've already seen many posts that are close:

How to disable “Security Alert” window in Webbrowser control -- doesn't work because WebBrowser apparently doesn't use the ServicePointManager

Suppressing Hosted WebBrowser Control Dialogs -- depends on knowing window titles, which doesn't work for a non-English audience

C# WebBrowser Control - ignore website security warnings -- this was closed as a duplicate, and the answer just referred to the above link.

Most form posts suggest implementing IInternetSecurityManager, which I've done, but to no avail.
Responding with a constant value for GetSecurityId for all URLs (specifying URLZONE_LOCAL_MACHINE or URLZONE_TRUSTED) doesn't work.

The following doesn't help:

public unsafe int MapUrlToZone(string url, int* pdwZone, int dwFlags)
{
    *pdwZone = 3; // URLZONE_TRUSTED;
    return Win32.S_OK;
}

Finally, I can't seem to find a way for ProcessUrlAction to have any effect:

public unsafe int ProcessUrlAction(string url, int dwAction, byte* pPolicy, int cbPolicy,
            byte* pContext, int cbContext, int dwFlags, int dwReserved)
{
    *((int*)pPolicy) = (int)Win32.UrlPolicy.URLPOLICY_ALLOW;
    return Win32.S_OK;
}

Has anyone successfully found a way past that SSL warning page?

See Question&Answers more detail:os

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Reply

0 votes
by (71.8m points)

the interface you need to implement is IHttpSecurity. See http://jiangsheng.net/2013/07/17/howto-ignoring-web-browser-certificate-errors-in-webbrowser-host/ for an example based on Windows Forms.


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
OGeek|极客中国-欢迎来到极客的世界,一个免费开放的程序员编程交流平台!开放,进步,分享!让技术改变生活,让极客改变未来! Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...