Android and libCurl https

岁酱吖の 提交于 2019-12-31 04:24:05

问题


Good evening,

I need to implement libCurl into one of our Android projects. I use JNI to call the c++ class with the libCurl code. Everything works just perfect but for the love of god I can't get it to work using a https url. I always get the CURLE_UNSUPPORTED_PROTOCOL error.

I'm using this prebuild curl library with SSL

My c++ code looks like this:

curl_easy_setopt(curl, CURLOPT_URL, "https://www.es....");
curl_easy_setopt(curl, CURLOPT_WRITEFUNCTION, write_data);
curl_easy_setopt(curl, CURLOPT_WRITEDATA, (void *)&chunk);
curl_easy_setopt(curl, CURLOPT_NOPROGRESS, 0);
curl_easy_setopt(curl, CURLOPT_PROGRESSDATA, (void *)&cbProgress);
curl_easy_setopt(curl, CURLOPT_PROGRESSFUNCTION, progress_func);
curl_easy_setopt(curl, CURLOPT_SSLVERSION, 3);

status = curl_easy_perform(curl);

I use the same code for iOS and it works fine with https. Again, using a http url works just fine.

Any help is truly appreciated !!


回答1:


From libcurl errors manpage:

   CURLE_UNSUPPORTED_PROTOCOL (1)
          The URL you passed to libcurl used a protocol that this  libcurl
          does  not  support.  The  support might be a compile-time option
          that you didn't use, it can be a misspelled protocol  string  or
          just a protocol libcurl has no code for.

The compile-time option is the important takeaway of this. So, test the library that you're using with curl_version_info() (manpage here) to see if it contains SSL support or not. The library doc may say it has SSL support, but please confirm. If it doesn't contain SSL support, then no https.




回答2:


You need compile libcurl.so with "--with-ssl"

Which is really suffering. Refer "http://ieroot.com/2015/03/29/1728.html", may help you .



来源:https://stackoverflow.com/questions/17873242/android-and-libcurl-https

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!