小编Rob*_*hou的帖子

如何让SSL peer_verify在Android上运行?

我在Android上用openssl-1.0.1h成功构建了libcurl-7.36.0.我运行了一个示例代码来测试HTTPS连接.默认情况下启用SSL_VERIFYPEER.Android上的证书路径是/ system/etc/security/cacerts,因此我将CURLOPT_CAPATH设置为/ system/etc/security/cacerts.

ls -l /system/etc/security/cacerts
-rw-r--r-- root     root         4767 2012-09-22 11:57 00673b5b.0
-rw-r--r-- root     root         4573 2012-09-22 11:57 03e16f6c.0
-rw-r--r-- root     root         5292 2012-09-22 11:57 08aef7bb.0
......
Run Code Online (Sandbox Code Playgroud)

这是我的代码片段..

curl = curl_easy_init();
curl_easy_setopt(curl, CURLOPT_URL, "https://www.google.com:443");
curl_easy_setopt(curl, CURLOPT_SSL_VERIFYPEER, 1L);     // default
curl_easy_setopt(curl, CURLOPT_CAPATH, "/system/etc/security/cacerts");
curl_easy_perform(curl);
Run Code Online (Sandbox Code Playgroud)

Curl始终返回错误:

== Info: SSL certificate problem: unable to get local issuer certificate  
== Info: Closing connection 0  
curl_easy_perform() failed: Peer certificate cannot be authenticated with given CA certificates
Run Code Online (Sandbox Code Playgroud)

它的工作,如果我请从CA包文件CA-bundle.crt http://curl.haxx.se/docs/caextract.htmlcurl_easy_setopt(curl, CURLOPT_CAINFO, "path:/ca-bundle.crt").

这是我的问题:有没有办法通过从 …

openssl libcurl android-ndk

13
推荐指数
3
解决办法
4441
查看次数

标签 统计

android-ndk ×1

libcurl ×1

openssl ×1