我在Windows 7上运行PHP Version 5.6.3作为XAMPP的一部分。

当我尝试使用Mandrill API时,我得到以下错误:

未捕获的异常“Mandrill_HttpError”与消息“API调用消息/发送模板失败:SSL证书问题:无法获得本地颁发者证书”

我已经尝试了我在StackOverflow上读到的所有内容,包括将以下内容添加到php.ini文件:

curl.cainfo = "C:\xampp\php\cacert.pem"

当然也下载到了cacert。来自http://curl.haxx.se/docs/caextract.html的Pem文件

但是在这之后,重新启动XAMPP和Apache服务器,但仍然得到相同的错误。

我真的不知道还能试什么。

有没有人能建议我还能尝试些什么?


当前回答

简单地把两个更多的线在本地解决问题,这为我工作很好。

curl_setopt($ch, CURLOPT_SSL_VERIFYHOST, false);
curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, false);

其他回答

终于让这个工作了!

Download the certificate bundle. Put it somewhere. In my case, that was c:\wamp\ directory (if you are using Wamp 64 bit then it's c:\wamp64\). Enable mod_ssl in Apache and php_openssl.dll in php.ini (uncomment them by removing ; at the beginning). But be careful, my problem was that I had two php.ini files and I need to do this in both of them. One is the one you get from your WAMP taskbar icon, and another one is, in my case, in C:\wamp\bin\php\php5.5.12\ Add these lines to your cert in both php.ini files: curl.cainfo="C:/wamp/cacert.pem" openssl.cafile="C:/wamp/cacert.pem" Restart Wamp services.

如果你不能访问php.ini,添加这段代码(在$ch = curl_init();行)适合我:

$certificate_location = "C:\Program Files (x86)\EasyPHP-Devserver-16.1\ca-bundle.crt"; // modify this line accordingly (may need to be absolute)
curl_setopt($ch, CURLOPT_CAINFO, $certificate_location);
curl_setopt($ch, CURLOPT_CAPATH, $certificate_location);

然后,您只需要下载ca-bundle。CRT并保存到您在$certificate_location中指定的位置。

上面的步骤虽然有帮助,但在Windows 8上并不适用。我不知道其中的关联,但以下步骤是有效的。基本上是cacert的变化。pem文件。希望这能帮助到一些人。

下载cacert。Pem文件: http://curl.haxx.se/docs/caextract.html 将该文件保存在PHP安装文件夹中。(例如:如果使用xampp -保存在c:\Installation_Dir\xampp\php\cacert.pem)。 打开你的php.ini文件,添加这些行: curl.cainfo = " C: \ Installation_Dir \ xampp \ php \ cacert.pem” openssl.cafile = " C: \ Installation_Dir \ xampp \ php \ cacert.pem” 重新启动Apache服务器应该就能解决问题了(只需停止并启动 根据需要提供服务)。

编者注:禁用SSL验证存在安全隐患。如果不验证SSL/HTTPS连接的真实性,恶意攻击者可以模拟可信端点(如GitHub或其他远程Git主机),您将容易受到中间人攻击。 在使用此解决方案之前,请确保您完全理解安全问题。

我试过了,很管用

open

vendor\guzzlehttp\guzzle\src\Handler\CurlFactory.php

改变这个

 $conf[CURLOPT_SSL_VERIFYHOST] = 2;
 $conf[CURLOPT_SSL_VERIFYPEER] = true;

这个

$conf[CURLOPT_SSL_VERIFYHOST] = 0;
$conf[CURLOPT_SSL_VERIFYPEER] = FALSE;

我得到的错误如下:

failed loading cafile stream: `C:\xamppPhp\apache\bin\curl-ca-bundle.crt`

我用的是windows电脑。所以我遵循以下步骤。

1. I have downloaded .pem file from " https://curl.haxx.se/docs/caextract.html "

2. Then I kept the downloaded file inside  "C:/xamppPhp/apache/bin/" folder and renamed the same downloaded file to "curl-ca-bundle.crt".

3. I restarted XAMPP and cleared the cache.
4. It's done.

希望它能帮助到一些人