我正在使用Microsoft的WinHttpRequestCOM对象来请求具有无效证书的网页:
IWinHttpRequest http = new WinHttpRequest();
http.Open("GET", url, false);
http.Send(null);
Run Code Online (Sandbox Code Playgroud)
除了调用Send抛出异常外:
0x80072F0D - The certificate authority is invalid or incorrect
Run Code Online (Sandbox Code Playgroud)
我怎么说WinHttpRequest我不在乎,我想要它检索我要求的页面?
解决方案是忽略四种SSL错误:
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);
Run Code Online (Sandbox Code Playgroud)
注意:任何代码都将发布到公共域中.无需归属.
| 归档时间: |
|
| 查看次数: |
9366 次 |
| 最近记录: |