cURL出现Mandrill CA SSL错误


Mandrill CA SSL errors with cURL

我正在试用Mandrill。看起来不错。我注册了一个帐户并获得了一个api密钥。已从下载Mandrill PHP包装https://bitbucket.org/mailchimp/mandrill-api-php

这篇文章似乎有一个很好的hello world Mandrill电子邮件示例,所以我尝试了一下:

使用Mandrill 发送电子邮件的简单php函数

一直得到这个错误:

API call to templates/add failed: Problem with the SSL CA cert (path? access rights?)

我遵循了这些S.O.帖子的指示:

使用Mandrill(php)发送电子邮件时出错HTTPS和SSL3_GET_SERVER_CERTIFICATE:证书验证失败,CA正常

从中获取.pem文件http://curl.haxx.se/docs/caextract.html

并确保curl api指向Mandrill api 中的那个文件

curl_setopt ($ch, CURLOPT_SSL_VERIFYPEER, TRUE); 
curl_setopt ($ch, CURLOPT_CAINFO, "pathto/cacert.pem");

.pem文件可读。没有疯狂的权限情况。

没有帮助。相同交易:

API call to templates/add failed: Problem with the SSL CA cert (path? access rights?)

在谷歌上搜索时,我遵循了CentOS 6.0的步骤:http://kb.kerio.com/product/kerio-connect/server-configuration/ssl-certificates/adding-trusted-root-certificates-to-the-server-1605.html

以及此处的步骤:http://unitstep.net/blog/2009/05/05/using-curl-in-php-to-access-https-ssltls-protected-sites/

同样的错误。作为最后一次尝试,我将curl设置为完全忽略ssl步骤。这当然不是建议,但我只是想感觉脚下有坚实的地面。我回到Mandrill.php,尝试了一下。

curl_setopt($this->ch, CURLOPT_SSL_VERIFYHOST, 0);
curl_setopt($this->ch, CURLOPT_SSL_VERIFYPEER, 0);

同样的错误。我想知道其他人是否能为我提供一些线索。我已经用光了谷歌。(它给了我一个重述,因为我用得太多了)。谢谢你抽出时间!

(系统:CentOS 6.5,PHP 5.3)

很奇怪您在Linux上遇到了这个问题(不过在Windows中是已知的问题)。

我唯一能想到的是,您尝试通过php.ini文件加载.pem作为默认值,检查curl.cainfo并提供cacert.pem-文件的绝对路径。这样你就不必使用CURLOPT_CAINFO了——也许会得到更好的结果?

离题一半如果你不需要API提供的所有功能,你也可以使用SMTP连接(总是更容易使用)。