(I am under windows) I am trying to download a zip file located at a given url as follows :
CURL *curl;
FILE *fp;
CURLcode res;
char *url = "https://www.markit.com/news/InterestRates_USD_20090102.zip";
char outfilename[FILENAME_MAX] = "C:\\InterestRates_USD_20090102.zip";
curl_version_info_data * vinfo = curl_version_info(CURLVERSION_NOW);
if (vinfo->features & CURL_VERSION_SSL)
{
printf("CURL: SSL enabled\n");
}
else {
printf("CURL: SSL not enabled\n");
}
curl = curl_easy_init();
if (curl)
{
curl_easy_setopt(curl, CURLOPT_URL, url);
curl_easy_setopt(curl, CURLOPT_FOLLOWLOCATION, 1L);
curl_easy_setopt(curl, CURLOPT_NOSIGNAL, 1); //Prevent "longjmp causes uninitialized stack frame" bug
fp = fopen(outfilename, "wb");
int errnum = 0;
if (nullptr == fp)
{
errnum = errno;
fprintf(stderr, "Value of errno: %d\n", errno);
perror("Error printed by perror");
fprintf(stderr, "Error opening file: %s\n", strerror(errnum));
}
curl_easy_setopt(curl, CURLOPT_CAINFO, "./ca-bundle.crt");
curl_easy_setopt(curl, CURLOPT_SSL_VERIFYPEER, false);
curl_easy_setopt(curl, CURLOPT_SSL_VERIFYHOST, false);
curl_easy_setopt(curl, CURLOPT_WRITEFUNCTION, write_data);
curl_easy_setopt(curl, CURLOPT_WRITEDATA, fp);
res = curl_easy_perform(curl);
curl_easy_cleanup(curl);
}
A file C:\\InterestRates_USD_20090102.zip
appears indeed, but it is a directory named InterestRates_USD_20090102.zip
, not a zip file.
I don't think the problem is the zip format but rather the https url (I of course download manually the file with no problem) as res
shows CURLE_UNSUPPORTED_PROTOCOL
at debug. I indeed tried a lot of file format without https and had no problem, whereas any file format with https gives me the CURLE_UNSUPPORTED_PROTOCOL
at debug ...
I found this page :
but was unable to adapt, as inspincting the security details of the page (under chrome --> developer option --> security) yielded to an uncompatible certificate (not of the crt format)
Note that I have this problem whether I used "DLL" or "DLL Windows SSPI - DLL WinIDN", the latter including windows sll, see here : Curl 7.43.0 won't build in MSVC 2013