【问题标题】:Alternative to URLDownloadToFile functionURLDownloadToFile 函数的替代方法
【发布时间】:2012-01-11 12:40:43
【问题描述】:

URLDownloadToFile 函数是否有任何替代方法?我无法从具有无效证书的 HTTPS 服务器下载任何内容。是否有任何通用 HTTP 客户端可用于从具有无效证书的 HTTPS 服务器下载文件?这种情况还有其他选择吗?谢谢!

【问题讨论】:

    标签: c++ winapi https httpclient wininet


    【解决方案1】:

    您可以尝试libcurl,一个易于使用的客户端 URL 传输库。

    Here谈如何用它来处理ssl cert。

    【讨论】:

    【解决方案2】:

    尝试使用 CInternetSession::OpenURL。我不确定它是否有助于解决无效证书的问题,但您要求 URLDownloadToFile 的替代方法。

        CInternetSession connection;
        CStdioFile* stream = connection.OpenURL("https://www.google.com");
    
        const int capacity = 10000;
        char* buffer = new char[capacity];
        int bytes_read = stream->Read(buffer, capacity);
    
        FILE* output = fopen("C:\\output.html", "w");
        fwrite(buffer, 1, bytes_read, output);
        fclose(output);
    

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2021-08-04
      • 1970-01-01
      • 2012-10-18
      • 2020-01-07
      • 2019-05-02
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多