curl: (60) SSL certificate problem: unable to get local issuer certificate 错误

curl: (60) SSL certificate problem: unable to get local issuer certificate 错误

SSL certificate problem: unable to get local issuer certificate。

的错误信息。

此问题的出现是由于没有配置信任的服务器HTTPS验证。默认,cURL被设为不信任任何CAs,就是说,它不信任任何服务器验证。

因此,这就是浏览器无法通过HTTPs访问你服务器的原因。
 


解决此报错有2种处理方法

  1.如果你的内容不敏感,一个快捷的方法是使用curl_exec()之前跳过ssl检查项。

  curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, false);
  2.下载一个ca-bundle.crt ,放到对应的目录,在php.ini文件中配置下路径

  https://github.com/bagder/ca-bundle/blob/e9175fec5d0c4d42de24ed6d84a06d504d5e5a09/ca-bundle.crt

  在php.ini加入 ,重启web服务器

curl.cainfo="真实路径/ca-bundle.crt"

注:项目使用的是laravel框架,在window电脑下,我首先查找的是如下链接:

http://stackoverflow.com/questions/24611640/curl-60-ssl-certificate-unable-to-get-local-issuer-certificate


解决办法如下:

证书在 https://curl.haxx.se/docs/caextract.html 链接里面。

关于“SSL证书问题:无法获取本地颁发者证书”错误。很明显,这适用于发送CURL请求的系统(并且没有服务器接收请求)

1)从https://curl.haxx.se/ca/cacert.pem下载最新的cacert.pem

2)将以下行添加到php.ini(如果这是共享托管,并且您无法访问php.ini,那么可以在public_html中添加到.user.ini)

curl.cainfo=/path/to/downloaded/cacert.pem

3)默认情况下,FastCGI进程将每隔300秒解析新文件(如果需要,可以通过添加几个文件来更改频率,如https://ss88.uk/blog/fast-cgi-and-user-ini -files-the-new-htaccess /)


但是,下载的证书不可用,然后只好用

https://github.com/bagder/ca-bundle/blob/e9175fec5d0c4d42de24ed6d84a06d504d5e5a09/ca-bundle.crt

链接提供的证书解决了问题。

将下载的证书放在php.ini的当前目录下的extras/ssl/下面。

然后在php.ini文件中加入

curl.cainfo="真实路径/ca-bundle.crt"(curl扩展是必须开启的)


 

解决参考原文:


Thanks @Mladen Janjetovic,

Your suggestion worked for me in mac with ampps installed.

Copied: http://curl.haxx.se/ca/cacert.pem

To: /Applications/AMPPS/extra/etc/openssl/certs/cacert.pem

And updated php.ini with that path and restarted 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"
And applied same setting in windows AMPPS installation and it worked perfectly in it too.

[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"
Same for 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"
share
edited Jan 16 at 23:18
answered  Jan 28 '16 at 2:13
 
Damodar Bashyal
463 1 6 26
     
add a comment
up vote
15
down vote
When you view the http://curl.haxx.se/docs/caextract.html page, you will notice in big letters a section called:

RSA-1024 removed

Read it, then download the version of the certificates that includes the 'RSA-1024' certificates.https://github.com/bagder/ca-bundle/blob/e9175fec5d0c4d42de24ed6d84a06d504d5e5a09/ca-bundle.crt

Those will work with Mandrill.

Disabling SSL is a bad idea.


 


 


————————————————
版权声明:本文为CSDN博主「从心所愿」的原创文章,遵循CC 4.0 BY-SA版权协议,转载请附上原文出处链接及本声明。
原文链接:https://blog.csdn.net/sanbingyutuoniao123/article/details/71124655

  • 0
    点赞
  • 1
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
当你遇到 `cURL Error: SSL certificate problem: unable to get local issuer certificate` 错误时,这通常表示 cURL 在尝试与某个服务器建立安全(HTTPS)连接时,它无法验证服务器提供的 SSL 证书。具体来说,cURL 无法从本地的信任存储(通常是操作系统或证书管理工具如 OpenSSL)中找到服务器证书的签发机构(CA,Certificate Authority)的证书。 解决这个问题通常有以下几个步骤: 1. **检查证书库**:确保你的系统中包含了必要的 CA 证书。在 Windows 上,这些证书通常由操作系统提供;在 Linux 或 macOS 上,可能需要手动安装或更新 ca-certificates 或 curl 安装包中的证书。 2. **更新证书**:如果证书已过期或不是最新的,你可以下载最新的根证书文件,并将其添加到系统证书路径中。 3. **使用 --cacert 选项**:cURL 提供了 `--cacert` 选项,指定一个包含受信任 CA 证书的文件,这样 cURL 就会使用这个文件来验证服务器证书。 4. **临时解决方案**:如果只需要暂时解决,你可以用 `--insecure` 参数忽略证书问题,但这不是长久之计,因为这会降低网络连接的安全性。 5. **证书错误代码**:了解具体的错误代码可以帮助你更精确地定位问题。例如,某些错误可能是由于证书被吊销或者证书链不完整导致的。 相关问题: 1. 如何检查和更新我的系统中的SSL证书库? 2. cURL 的哪些参数可以用来指定自定义的CA证书文件? 3. 证书过期会对cURL请求产生什么影响?

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值