ssl证书问题:无法获取本地颁发者证书xampp

时间:2017-09-26 13:47:52

标签: php ssl curl

我对他们之前遇到的同样问题感到震惊,希望有人可以帮助我。

我的客户端已将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证书问题:无法获得本地颁发者证书"

我添加了#34; 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 个答案:

答案 0 :(得分:0)

在Windows XAMP中,使用CURL时我必须设置curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, FALSE);我知道这是一种错误。

显然,这会绕过使用SSL时的预期验证,因此它仅适用于开发。