我在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服务器,但仍然得到相同的错误。

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

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


当前回答

你可以试试这个:

$client = new Client(env('API_HOST'));
$client->setSslVerification(false);

测试在guzzle/guzzle 3.*

其他回答

我在AppVeyor开发应用时也遇到了同样的问题。

下载https://curl.haxx.se/ca/cacert.pem到c:\php 开启openssl echo extension=php_openssl.dll >> c:\php\php.ini 找到certificateecho curl.cainfo=c:\php\cacert。Pem >> c:\php\php.ini

上面的步骤虽然有帮助,但在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服务器应该就能解决问题了(只需停止并启动 根据需要提供服务)。

如果你不能访问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中指定的位置。

你可以试试这个:

$client = new Client(env('API_HOST'));
$client->setSslVerification(false);

测试在guzzle/guzzle 3.*

我有非常简单的解决这个问题。您可以在没有任何证书文件的情况下完成此操作。

注意,此解决方案适用于本地系统,而不适用于客户端服务器和生产服务器。

继续Laravel根文件夹-> vendor -> guzzlehttp -> guzzle -> src

打开Client.php

查找$defaults数组。看起来像这样。

$defaults = [
    'allow_redirects' => RedirectMiddleware::$defaultSettings,
    'http_errors'     => true,
    'decode_content'  => true,
    'verify'          => true,
    'cookies'         => false
];

现在主要工作是更改验证键的值..

'verify'          => false,

所以在这之后,它将不会检查SSL证书为CURL请求…这个解决方案对我来说就是工作。经过多次研究,我找到了这个解决方案…