如何让 WebBrowser 导航到不受信任的站点?
How do I get WebBrowser to Navigate to an untrusted site?
我已经实例化了一个 WebBrowser 对象。当我使用它导航到我需要它到达的特定 URL 时,我收到以下错误消息:
The website’s security certificate is not secure.
Error code: 0
问题是我无法在 WebBrowser 上解决这个错误。
但是,如果我使用 Internet Explorer 11 访问同一个 URL,我会得到一个类似的(可能是相同的?)错误,但有更多信息:
Your PC doesn’t trust this website’s security certificate.
The hostname in the website’s security certificate differs from the website you are trying to visit.
Error Code: DLG_FLAGS_INVALID_CA
DLG_FLAGS_SEC_CERT_CN_INVALID
它为我提供了选项 Go on to the webpage (not recommended)
。
这是我用来导航到网页的代码:
WebBrowser wb = new WebBrowser();
wb.ScriptErrorsSuppressed = true;
wb.Navigate(url);
wb.Dock = DockStyle.Fill;
稍后我将 wb
添加到控件。
我需要我的应用程序忽略错误并继续访问网页,或者提供以与 Internet Explorer 11 类似的方式访问网页的选项。
我该怎么做?
安装证书后错误立即消失。
我已经实例化了一个 WebBrowser 对象。当我使用它导航到我需要它到达的特定 URL 时,我收到以下错误消息:
The website’s security certificate is not secure.
Error code: 0
问题是我无法在 WebBrowser 上解决这个错误。
但是,如果我使用 Internet Explorer 11 访问同一个 URL,我会得到一个类似的(可能是相同的?)错误,但有更多信息:
Your PC doesn’t trust this website’s security certificate.
The hostname in the website’s security certificate differs from the website you are trying to visit.
Error Code: DLG_FLAGS_INVALID_CA
DLG_FLAGS_SEC_CERT_CN_INVALID
它为我提供了选项 Go on to the webpage (not recommended)
。
这是我用来导航到网页的代码:
WebBrowser wb = new WebBrowser();
wb.ScriptErrorsSuppressed = true;
wb.Navigate(url);
wb.Dock = DockStyle.Fill;
稍后我将 wb
添加到控件。
我需要我的应用程序忽略错误并继续访问网页,或者提供以与 Internet Explorer 11 类似的方式访问网页的选项。
我该怎么做?
安装证书后错误立即消失。