NDK、JNI 和 libcurl

发布于 2024-12-01 03:27:30 字数 224 浏览 7 评论 0 原文

我接手了一个项目,但在实施 SSL 方面遇到了困难。我们的应用程序使用 libcurl 从服务器访问远程内容。该设备正在寻找我拥有的 cacert.pem 文件,但不确定将其放置在哪里。我尝试将其放置在应用程序的根目录中,但这没有帮助。

同事建议将该文件直接放入 /sdcard,但这也没有帮助。

有谁知道我应该将 cacert.pem 文件放在应用程序中的哪个位置以使其能够被 libcurl 使用?

I've taken over a project and am having a hard time implementing the SSL side of things. Our application makes use of libcurl to access remote content from a server. The device is looking for a cacert.pem file to which I have, but am unsure where to place it. I've tried to place it in the root of the application but that did not help.

Co workers suggested the file should be placed directly into /sdcard but that did not help either.

Does anyone know where I should place the cacert.pem file within the application to enable it to be used by libcurl?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

深陷 2024-12-08 03:27:30

您可以使用 curl_easy_setoptCURLOPT_CAINFO 指定 libcurl 在何处查找 CA 信息:

  static const char *pCACertFile="cacert.pem";

  /* ... */

  /* set the file with the certs vaildating the server */ 
  curl_easy_setopt(curl, CURLOPT_CAINFO, pCACertFile);

以下示例演示了完整的 SSL 会话,包括指定 CA 证书文件:

http://curl.haxx.se/libcurl/c/simpllessl.html

You can specify where libcurl looks for the CA information using curl_easy_setopt with CURLOPT_CAINFO:

  static const char *pCACertFile="cacert.pem";

  /* ... */

  /* set the file with the certs vaildating the server */ 
  curl_easy_setopt(curl, CURLOPT_CAINFO, pCACertFile);

The following example demonstrates a full SSL session, including specifying the CA certificate file:

http://curl.haxx.se/libcurl/c/simplessl.html

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文