我很惊讶他们之前遇到的同样问题,希望有人可以帮助我 .
我的客户端已将SSL证书添加到服务器后,我收到此错误 .
我一整天都在谷歌和论坛上搜索但是无法修复它所以最后我在这里发布它 .
我的代码如下:
$ch = curl_init();
curl_setopt($ch, CURLOPT_URL,$url);
curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, TRUE);
curl_setopt($ch, CURLOPT_SSL_VERIFYHOST, 2);
curl_setopt($ch, CURLOPT_VERBOSE, 1);
//curl_setopt ($ch, CURLOPT_CAINFO, dirname(__FILE__)."\cacert.pem");
curl_setopt ($ch, CURLOPT_CAPATH, dirname(__FILE__)."\cacert.pem");
curl_setopt($ch, CURLOPT_STDERR, fopen(dirname(__FILE__)."/curl_debug.txt", "w+"));
if(curl_exec($ch) === false)
{
echo 'Curl error: ' . curl_error($ch);
}
exit;
我已将这两行添加到php.ini文件中:
[curl]
curl.cainfo="C:\xampp\perl\vendor\lib\Mozilla\CA\cacert.pem"
[openssl]
openssl.cafile="C:\xampp\perl\vendor\lib\Mozilla\CA\cacert.pem"
并尝试下载最新的cacert.pem文件
并通过给出文件的绝对路径来尝试上面的代码:
//curl_setopt ($ch, CURLOPT_CAINFO, dirname(__FILE__)."\cacert.pem");
什么都行不通,我得到的是同样的错误:
卷曲错误:SSL证书问题:无法获取本地颁发者证书“
我添加了“CURLOPT VERBOSE”来详细查看,下面是我收到的内容:
* Hostname in DNS cache was stale, zapped
* Trying xxx.xxx.x.x...
* Connected to mywebsite.com (xxx.xxx.x.x) port 443 (#0)
* Cipher selection: ALL:!EXPORT:!EXPORT40:!EXPORT56:!aNULL:!LOW:!RC4:@STRENGTH
* successfully set certificate verify locations:
* CAfile: C:\xampp\perl\vendor\lib\Mozilla\CA\cacert.pem
CApath: C:\xampp\htdocs\projects\myproject\includes\cacert.pem
* SSL certificate problem: unable to get local issuer certificate
* Closing connection 0
注意:我添加了CAPath,因为它未显示 CAPath : None
.
如果有人能就上述建议我会很好 .
非常感谢
1 回答
在Windows XAMP中,当使用CURL时我必须设置
curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, FALSE);
我明白这是某种bug .显然,这会绕过使用SSL时的预期验证,因此它仅适用于开发 .