【问题标题】:CodeIgniter-cURL on self assign certificate [duplicate]自分配证书上的 CodeIgniter-cURL [重复]
【发布时间】:2015-11-06 03:45:07
【问题描述】:

我正在使用 codeigniter-curl 扩展 (https://github.com/philsturgeon/codeigniter-curl) 来调用返回 Json 格式数据的 API。

一个简单的代码,它将返回结果等

$this->curl->simple_get(http://example.com/Json/GetHotDealRedemptionProduct?APIid=888ef4d078ca&Language=en&hash=3709aa6e0efe3c95e955a1981118027a2fde0eddc216b4049e6559af55f50458);

在 URL 更改为 HTTPS 之前一切正常。

为了调用 SSL url(自签名证书),我在 $this->curl->simple_get.... 代码上方添加了这几行。

$this->curl->create($this->url);
$this->curl->ssl(true, 2, 'assets/AIMS-BSN-WEB01.crt'); 

我从 firefox 证书查看器中保存的 cacert.pem 并将其放在我的 web 目录中。参考:http://unitstep.net/blog/2009/05/05/using-curl-in-php-to-access-https-ssltls-protected-sites/

我得到了这个错误。

error code: 60
SSL certificate problem: unable to get local issuer certificate

我已经搜索了一天的答案,

  1. 更改了 php.ini 设置Amazon S3 on wamp localhost SSL error

  2. 为 CURLOPT_SSL_VERIFYPEER 设置为 false。它返回SSL: certificate subject name 'AIMS-BSN-WEB01' does not match target host name 'api.example.com'

所有这些都不起作用。

【问题讨论】:

  • 尝试指定 'assets/cacert.pem' 的完整路径
  • 是的。在 $this->curl->ssl 函数中,它将把它变成 realpath "C:/wamp/www/assets/cacert.pem"
  • 对不起,因为是自签名认证,名称应该是 AIMS-BSN-WEB01.crt 而不是 cacert.pem

标签: php codeigniter ssl curl https


【解决方案1】:

好的。我设法通过跳过验证认证的对等方或主机来解决它 - PHP CURL CURLOPT_SSL_VERIFYPEER ignored

我没有将 FALSE 放在 CURLOPT_SSL_VERIFYPEER 中,而是使用 0。

$this->option(CURLOPT_SSL_VERIFYPEER, 0);
$this->option(CURLOPT_SSL_VERIFYHOST, 0);

现在可以了。

【讨论】:

猜你喜欢
  • 2021-10-06
  • 2018-08-07
  • 2021-02-20
  • 2020-09-20
  • 1970-01-01
  • 2014-02-06
  • 2022-01-26
  • 2021-12-14
  • 2013-09-28
相关资源
最近更新 更多