问题
i am using Microsoft's WinHttpRequest COM object to request a web-page with an invalid certificate:
IWinHttpRequest http = new WinHttpRequest();
http.Open("GET", url, false);
http.Send(null);
Except that the call to Send
throws an exception:
0x80072F0D - The certificate authority is invalid or incorrect
How do i tell WinHttpRequest
that i don't care, and i want it to retrieve the page i asked for?
回答1:
The solution is to ignore 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);
Note: Any code is released into the public domain. No attribution required.
来源:https://stackoverflow.com/questions/12080824/how-to-ignore-invalid-certificates-with-iwinhttprequest