Warning: file_get_contents(/data/phpspider/zhask/data//catemap/1/php/298.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Php ssl证书颁发:无法获取本地颁发者证书xampp_Php_Ssl_Curl - Fatal编程技术网

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

Php ssl证书颁发:无法获取本地颁发者证书xampp,php,ssl,curl,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_

他们中的许多人以前也遇到过同样的问题,希望有人能帮助我

在客户端将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");
什么都不管用,我得到的都是同样的错误:

Curl错误: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

如果有人能就上述问题向我提供建议,那就太好了


非常感谢

在Windows XAMP中,当使用CURL时,我必须设置
CURL\u setopt($ch,CURLOPT\u SSL\u VERIFYPEER,FALSE);
我知道这是某种错误


显然,这绕过了使用SSL时要进行的验证,因此它只是用于开发的一种变通方法。

1)它是有效的证书还是自签名的?2)curl在哪里运行,是在本地开发XAMP上还是在托管等生产环境中?SSL是由Comodo发布的,它在本地开发XAMPP上运行在我的loc中所有主机请尝试在路径中使用
/
而不是\因此,请查看此处,该文件似乎缺少正确的证书。如果您从中使用cacert.pem会怎么样?