我正在使用Microsoft的WinHttpRequest
COM对象来请求包含无效证书的网页:
IWinHttpRequest http = new WinHttpRequest();
http.Open("GET", url, false);
http.Send(null);
除了对Send
的调用引发异常外:
0x80072F0D - The certificate authority is invalid or incorrect
我如何告诉WinHttpRequest
我不在乎,我希望它能够检索我要求的页面?
答案 0 :(得分:7)
解决方案是忽略four kinds of SSL errors:
IWinHttpRequest http = new WinHttpRequest();
http.Open("GET", url, false);
//ignore all SSL errors
http.Option[WinHttpRequestOption_SslErrorIgnoreFlags] = SslErrorFlag_Ignore_All;
//SslErrorFlag_Ignore_All 0x3300
//Unknown certification authority (CA) or untrusted root 0x0100
//Wrong usage 0x0200
//Invalid common name (CN) 0x1000
//Invalid date or certificate expired 0x2000
http.Send(null);
注意:任何代码都会发布到公共域中。无需归属。