问题描述
晚上好,
我需要实现的libcurl到我们的Android项目之一。我用JNI调用C ++类与libcurl的code。一切正常,只是完美的,但在上帝的爱,我不能让它使用HTTPS URL工作。我总是得到CURLE_UNSUPPORTED_PROTOCOL错误。
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.
我使用这prebuild curl库与SSL
我的C ++ code是这样的:
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);
我用同样的code iOS和它工作正常使用HTTPS。同样,使用一个HTTP URL工作得很好。
I use the same code for iOS and it works fine with https.Again, using a http url works just fine.
任何帮助是真正的AP preciated !!
Any help is truly appreciated !!
推荐答案
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.
在编译时间选项
是这个重要的外卖。因此,测试您使用的是与 curl_version_info()
(手册页的),看它是否包含 SSL
支持与否。库文档可以说它 SSL
的支持,但请确认。如果它不包含 SSL
支持,则没有 HTTPS
。
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
.
这篇关于Android和libcurl的HTTPS的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!