【发布时间】: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
我已经搜索了一天的答案,
更改了 php.ini 设置Amazon S3 on wamp localhost SSL error
为 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