我在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);

其他回答

谢谢@Mladen Janjetovic,

你的建议在安装了放大器的mac上对我有用。

复制:http://curl.haxx.se/ca/cacert.pem

: /应用程序/ ampp /额外的/ etc / openssl /组/ cacert.pem

用这个路径更新php.ini并重新启动Apache:

[curl]
; A default value for the CURLOPT_CAINFO option. This is required to be an
; absolute path.
curl.cainfo="/Applications/AMPPS/extra/etc/openssl/certs/cacert.pem"
openssl.cafile="/Applications/AMPPS/extra/etc/openssl/certs/cacert.pem"

并在windows AMPPS安装中应用了相同的设置,效果也很好。

[curl]
; A default value for the CURLOPT_CAINFO option. This is required to be an
; absolute path.
curl.cainfo="C:/Ampps/php/extras/ssl/cacert.pem"
openssl.cafile="C:/Ampps/php/extras/ssl/cacert.pem"

: wamp也是一样。

[curl]
; A default value for the CURLOPT_CAINFO option. This is required to be an
; absolute path.
curl.cainfo="C:/wamp/bin/php/php5.6.16/extras/ssl/cacert.pem"
openssl.cafile="C:/wamp/bin/php/php5.6.16/extras/ssl/cacert.pem"

如果您正在寻找使用SAN为localhost生成新的SSL证书,那么本文中的步骤在Centos 7 / Vagrant / Chrome浏览器上对我有效。

可能发生此错误的另一个原因是,如果CA包已从系统中删除(并且在CA -certificates中不再可用)。

这是GeoTrust全球CA目前的情况,该CA(除其他外)用于为用于推送通知的APNS签署苹果证书。

更多详细信息可以在错误报告中找到:https://bugs.debian.org/cgi-bin/bugreport.cgi?bug=962596

您可以手动添加GeoTrust全球CA证书在您的机器上,建议由卡洛斯阿尔贝托洛佩兹佩雷斯:

wget --no-check-certificate -c https://www.geotrust.com/resources/root_certificates/certificates/GeoTrust_Global_CA.pem   \
&& mkdir /usr/local/share/ca-certificates/extra                                                                       \
&& mv GeoTrust_Global_CA.pem /usr/local/share/ca-certificates/extra/GeoTrust_Global_CA.crt                            \
&& update-ca-certificates

当你浏览http://curl.haxx.se/docs/caextract.html页面时,你会注意到一个用大字母写的部分:

RSA-1024把

阅读本文,然后下载包含“RSA-1024”证书的证书版本。 https://github.com/bagder/ca-bundle/blob/e9175fec5d0c4d42de24ed6d84a06d504d5e5a09/ca-bundle.crt

这些将与Mandrill一起工作。

禁用SSL是一个坏主意。

在亚马逊Linux (CentOS / Red Hat等)上,我做了以下工作来解决这个问题。首先复制cacert。Pem从http://curl.haxx.se/ca/cacert.pem下载,放在/etc/pki/ca-trust/source/anchors/目录下。执行update-ca-trust命令。

下面是来自https://serverfault.com/questions/394815/how-to-update-curl-ca-bundle-on-redhat的一句话

Curl https://curl.se/ca/cacert.pem -o /etc/pki/ca-trust/source/anchors/curl-cacert-updated。Pem && update-ca-trust

然而,由于curl被破坏,我实际上使用这个命令来下载cacert。pem文件。

Wget——no-check-certificate http://curl.haxx.se/ca/cacert.pem

执行update-ca-trust命令后,可以重新启动web服务器服务httpd restart (apache)或service nginx restart (nginx)。

你可以试试这个:

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

测试在guzzle/guzzle 3.*