Dor*_*ush 163 php xampp ssl curl mandrill
我在Windows 7上运行PHP版本5.6.3作为XAMPP的一部分.
当我尝试使用Mandrill API时,我收到以下错误:
未捕获的异常'Mandrill_HttpError',消息'API调用消息/发送模板失败:SSL证书问题:无法获取本地颁发者证书'
我已经尝试过在StackOverflow上阅读的所有内容,包括将以下内容添加到php.ini文件中:
curl.cainfo = "C:\xampp\php\cacert.pem"
Run Code Online (Sandbox Code Playgroud)
并且当然从http://curl.haxx.se/docs/caextract.html下载到该位置的cacert.pem文件
但毕竟,重新启动XAMPP和Apache服务器但仍然得到相同的错误.
我真的不知道还有什么可以尝试的.
任何人都可以建议我还能尝试什么?
Mla*_*vic 319
终于有了这个工作!
下载证书包.
把它放在某个地方.在我的情况下,那是c:\wamp\目录(如果您使用Wamp 64位,那么它c:\wamp64\).
mod_ssl在Apache和php_openssl.dll中启用php.ini(通过;在开头删除它们取消注释).但要小心,我的问题是我有两个php.ini文件,我需要在两个文件中都这样做.一个是从WAMP任务栏图标中获得的一个,另一个是在我的情况下,在C:\wamp\bin\php\php5.5.12\
将这些行添加到两个php.ini文件中的证书中:
curl.cainfo="C:/wamp/cacert.pem"
openssl.cafile="C:/wamp/cacert.pem"
Run Code Online (Sandbox Code Playgroud)重启Wamp服务.
She*_*ani 115
免责声明:此代码使您的服务器不安全.
在第65行之后我在Mandrill.php文件中遇到了同样的问题,它说$ this-> ch = curl_init();
添加以下两行:
curl_setopt($this->ch, CURLOPT_SSL_VERIFYHOST, 0);
curl_setopt($this->ch, CURLOPT_SSL_VERIFYPEER, 0);
Run Code Online (Sandbox Code Playgroud)
这解决了我的问题,并使用localhost发送电子邮件,但我建议不要在实时版本上使用它.在您的实时服务器上,代码应该没有此代码.
Dam*_*yal 44
谢谢@Mladen Janjetovic,
您的建议适用于安装了Ampps的mac.
复制: http ://curl.haxx.se/ca/cacert.pem
至: /Applications/AMPPS/extra/etc/openssl/certs/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"
Run Code Online (Sandbox Code Playgroud)
并在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"
Run Code Online (Sandbox Code Playgroud)
:同样适用于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"
Run Code Online (Sandbox Code Playgroud)
如果您正在寻找使用SAN为localhost生成新的SSL证书,这篇文章的步骤对我有用Centos 7 / Vagrant / Chrome Browser.
Art*_*ado 18
当您查看http://curl.haxx.se/docs/caextract.html 页面时,您会在大字母中注意到一个名为:
RSA-1024已删除
阅读它,然后下载包含"RSA-1024"证书的证书版本. https://github.com/bagder/ca-bundle/blob/e9175fec5d0c4d42de24ed6d84a06d504d5e5a09/ca-bundle.crt
这些将与Mandrill合作.
禁用SSL是个坏主意.
Hop*_*ing 10
上述步骤虽然有用,但在Windows 8上对我没有用.我不知道相关关系,但以下步骤有效.基本上是cacert.pem文件中的更改.希望这有助于某人.
我发现没有任何必要的认证的新解决方案只能添加两行代码.
curl_setopt($ch, CURLOPT_FOLLOWLOCATION, TRUE);
curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, false);
Run Code Online (Sandbox Code Playgroud)
如果您无法访问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);
Run Code Online (Sandbox Code Playgroud)
然后,您只需要下载ca-bundle.crt并将其保存到您指定的位置$certificate_location.
小智 6
注意:禁用 SSL 验证会产生安全隐患。如果不验证 SSL/HTTPS 连接的真实性,恶意攻击者就可以冒充受信任的端点(例如 GitHub 或其他一些远程 Git 主机),并且您将很容易受到中间人攻击。
在使用此解决方案之前,请确保您完全了解安全问题。
详细阐述上述服务器部署的答案。
$hostname = gethostname();
if($hostname=="mydevpc")
{
curl_setopt($ch, CURLOPT_FOLLOWLOCATION, TRUE);
curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, false);
}
Run Code Online (Sandbox Code Playgroud)
应该可以解决开发环境的问题,而不会在部署时影响服务器。
小智 6
编者注:禁用 SSL 验证会产生安全隐患。如果不验证 SSL/HTTPS 连接的真实性,恶意攻击者就可以冒充受信任的端点(例如 GitHub 或其他一些远程 Git 主机),并且您将很容易受到中间人攻击。
在使用此解决方案之前,请确保您完全了解安全问题。
我试过这个它有效
打开
vendor\guzzlehttp\guzzle\src\Handler\CurlFactory.php
Run Code Online (Sandbox Code Playgroud)
并改变这个
$conf[CURLOPT_SSL_VERIFYHOST] = 2;
$conf[CURLOPT_SSL_VERIFYPEER] = true;
Run Code Online (Sandbox Code Playgroud)
对此
$conf[CURLOPT_SSL_VERIFYHOST] = 0;
$conf[CURLOPT_SSL_VERIFYPEER] = FALSE;
Run Code Online (Sandbox Code Playgroud)
| 归档时间: |
|
| 查看次数: |
232875 次 |
| 最近记录: |