I recently tried to learn more about CURL and finally managed to compile and install it as a static library for my test project. In the end, I will move on to studying forms of publication, etc.
I was able to successfully install and print the contents of the page from http://www.google.se .
When connected to a secure http page https://www.google.se I get an empty string as the content of the page.
I use this to get parameter information.
I tried things from this answer , but it did not work, or I did it wrong.
I also tried disabling verifypeer and verifyhost (although I really want to practice secure solutions), but it does not work either.
What do I need to do to make it work? Am I doing something wrong?
Here is the test code
#include <iostream> #include <string> #include <curl/curl.h> using namespace std; static size_t WriteCallback(void *contents, size_t size, size_t nmemb, void *userp){ ((string*)userp)->append((char*)contents, size * nmemb); return size * nmemb; } int main(){ CURL *curl; CURLcode res; string readBuffer; curl = curl_easy_init(); if(curl){ curl_easy_setopt(curl, CURLOPT_URL, "https://www.google.se"); //curl_easy_setopt(curl, CURLOPT_FOLLOWLOCATION, TRUE); //Doesn't seem to work curl_easy_setopt(curl, CURLOPT_CAINFO, "path\\cacert.pem"); //Neither does this curl_easy_setopt(curl, CURLOPT_SSL_VERIFYPEER, FALSE); curl_easy_setopt(curl, CURLOPT_SSL_VERIFYHOST, FALSE); curl_easy_setopt(curl, CURLOPT_WRITEFUNCTION, WriteCallback); curl_easy_setopt(curl, CURLOPT_WRITEDATA, &readBuffer); res = curl_easy_perform(curl); curl_easy_cleanup(curl); cout<<readBuffer<<endl; system("pause"); } return 0; }
Update
So, I got an error from curl saying the Unsupported protocol , which I assume is what it says when SSL is down. So I had to recompile it using SSL (which is strange because I thought I did it the first time), but ...
I'm almost going to give up. Sigh. For one reason or another, now it gave me the NMAKE: fatal error U1077 nasmw when creating SSL, although I clearly gave it% PATH% to nasm. I followed the steps to the letter.
So I tried to use curl binaries like libcurl , but I donβt know how to properly link it in VC ++, because the library doesnβt know the files.
I keep getting these linker errors when trying to compile a test project.
1>main.obj : error LNK2019: unresolved external symbol _curl_easy_cleanup referenced in function _main 1>main.obj : error LNK2019: unresolved external symbol _curl_easy_strerror referenced in function _main 1>main.obj : error LNK2019: unresolved external symbol _curl_easy_perform referenced in function _main 1>main.obj : error LNK2019: unresolved external symbol _curl_easy_setopt referenced in function _main 1>main.obj : error LNK2019: unresolved external symbol _curl_easy_init referenced in function _main
So upset ... I would like to understand why this should be so difficult. I just want to use the library already!
Update 2
Ok ... I managed to compile the curl library with SSL and report CURL_VERSION_SSL
curl_version_info_data * vinfo = curl_version_info(CURLVERSION_NOW); if(vinfo->features & CURL_VERSION_SSL){ cout<<"CURL: SSL enabled"<<endl; }else{ cout<<"CURL: SSL not enabled"<<endl; }
but I still get the Unsupported protocol error message. I do not know what I am doing wrong.