【问题标题】:How to ignore invalid certificates with IWinHttpRequest?如何使用 IWinHttpRequest 忽略无效证书?
【发布时间】:2012-08-18 07:56:50
【问题描述】:

我正在使用 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 我不在乎,我希望它检索我要求的页面?

【问题讨论】:

    标签: winapi winhttp


    【解决方案1】:

    解决方法是忽略four kinds of SSL errors

    //Code is released into the public domain. No attribution required. 
    IWinHttpRequest http = new WinHttpRequest();
    http.Open("GET", url, false);
    
    //ignore any TLS errors 
    option = http.Option[WinHttpRequestOption_SslErrorIgnoreFlags];
    options = options | SslErrorFlag_Ignore_All;
    http.Option[WinHttpRequestOption_SslErrorIgnoreFlags] = option; 
    
        //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);
    

    【讨论】:

    • 这似乎不适用于 VB6,我仍然得到与 OP 相同的错误。
    猜你喜欢
    • 2019-01-16
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2016-05-18
    • 2011-05-28
    • 1970-01-01
    • 2015-03-19
    • 2011-10-11
    相关资源
    最近更新 更多