Mandrill PHP无法获取本地颁发者SSL证书


Mandrill PHP unable to get local issuer SSL certificate

我已经在我的Windows Apache服务器上安装了Mandrill PHP API。当尝试使用下面的代码发送电子邮件时,我得到了错误:

Mandrill_HttpError-对消息/发送模板的API调用失败:SSL证书问题:无法获取本地颁发者证书

我不清楚Mandrill是如何连接到我的本地颁发者证书的。我的web服务器确实有有效的证书,并且可以成功显示HTTPS页面。

有什么想法吗?

        $mandrill = new Mandrill('MyMandrillAPIKey');
        $message = array(
            'subject' => 'Test message',
            'from_email' => 'MyEmailAddress',
            'html' => '<p>this is a test message with Mandrill''s PHP wrapper!.</p>',
            'to' => array(array('email' => 'MyEmailAddress', 'name' => 'David Splat')),
            'merge_vars' => array(array(
                'rcpt' => 'MyEmailAddress',
                'vars' =>
                array(
                    array(
                        'name' => 'FIRSTNAME',
                        'content' => $fName),
                    array(
                        'name' => 'LASTNAME',
                        'content' => $lName)
            ))));
        $template_name = 'MyTemplateName';
        $template_content = array(
            array(
                'name' => 'main',
                'content' => 'Hi *|FIRSTNAME|* *|LASTNAME|*, thanks for signing up.'),
            array(
                'name' => 'footer',
                'content' => 'Copyright 2014.')
        );
        print_r($mandrill->messages->sendTemplate($template_name, $template_content, $message));
    } catch(Mandrill_Error $e) {
        // Mandrill errors are thrown as exceptions
        echo 'A mandrill error occurred: ' . get_class($e) . ' - ' . $e->getMessage();
        throw $e;
    }

您不需要关闭curl SSL选项,而是可以从http://curl.haxx.se/docs/caextract.html然后将其包含在php.ini文件中curl.cainfo="/exact/location/to/cacert.pem"

或者简单地更改Mandrill.php文件中的行以使用它,如下所示。

curl_setopt ($this->ch, CURLOPT_SSL_VERIFYPEER, TRUE); 
curl_setopt ($this->ch, CURLOPT_CAINFO, __DIR__ . "/cacert.pem")

链接到帖子http://tutewall.com/ssl-certificate-problem-unable-to-get-local-issuer-certificate/

这是一个修复了我的问题的更改。在Mandrill.php中,在调用curl_init()后添加这两行:

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

这种方法是由使用Mandrill(php)发送电子邮件时的一个错误答案提出的