Ștefan-Mihai MOGA
Ștefan-Mihai MOGA

Reputation: 343

Alternative to URLDownloadToFile function

Are there any alternative to the URLDownloadToFile function? I cannot download anything from an HTTPS server with invalid certificate. Are there any generic HTTP clients which I can use to download a file from an HTTPS server with an invalid certificate? Are there any other alternatives for this situation? Thank you!

Upvotes: 1

Views: 4958

Answers (2)

sashoalm
sashoalm

Reputation: 79477

Try using CInternetSession::OpenURL. I'm not sure if it helps with your problem with invalid certificates, but you were asking for alternatives to 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);

Upvotes: 2

user685684
user685684

Reputation: 182

You can try libcurl, a easy-to-use client-side URL transfer library.

Here talks about how to deal with ssl cert with it.

Upvotes: 2

Related Questions