无法弄清楚是什么原因:
在我的本地环境中,当我把OSX更新到Yosemite的最新版本后,出现了以下错误:
CurlException: [curl] 51: SSL: certificate verification failed (result: 5) [url]
我正在使用Symfony2,所以它涉及到PHP。我尝试重新安装openssl,但没有任何变化。有什么建议吗?
openssl s_client -host www.googleapis.com -port 443
CONNECTED(00000005)
depth=1 C = US, O = Google Trust Services, CN = Google Internet Authority G3
verify error:num=20:unable to get local issuer certificate
---
Certificate chain
0 s:/C=US/ST=California/L=Mountain View/O=Google Inc/CN=*.googleapis.com
i:/C=US/O=Google Trust Services/CN=Google Internet Authority G3
1 s:/C=US/O=Google Trust Services/CN=Google Internet Authority G3
i:/OU=GlobalSign Root CA - R2/O=GlobalSign/CN=GlobalSign
<?php echo phpinfo();
openssl.cafile
来查找从页面输出加载的证书文件:openssl.cafile openssl.cafile /usr/local/php5/ssl/certs/cacert.pem
sudo nano /usr/local/php5/ssl/certs/cacert.pem
(注意:这是一个图片,所以人们不能简单地从stackoverflow复制/粘贴证书)
openssl x509 -inform DER -outform PEM -in GIAG2.crt -out GIA2.pem
添加以下选项以忽略证书:
curl_setopt($ch, CURLOPT_SSL_VERIFYHOST, 0); curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, 0);
curl --cacert /path/to/cert.pem https://url
。我得到了相同的“51”错误。告诉PHP不设置证书似乎对我有用。请查看https://github.com/guzzle/guzzle/issues/819。 - Jonny Barnes