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"

 

原文:https://blog.csdn.net/sanbingyutuoniao123/article/details/71124655

版权声明:本文内容由互联网用户自发贡献,该文观点仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请联系我们举报,一经查实,本站将立刻删除。

发布者:全栈程序员-站长,转载请注明出处:https://javaforall.net/112795.html原文链接:https://javaforall.net

(0)
全栈程序员-站长的头像全栈程序员-站长


相关推荐

  • 注册境外邮箱有哪些_腾讯会员邮箱登录

    注册境外邮箱有哪些_腾讯会员邮箱登录TOMVIP邮箱可在客户端绑定,支持多个终端邮件同步。163VIP邮箱超大容量、邮件群发效果好、微信邮件实时提醒,企业版邮箱也可以使用误删恢复功能。

    2022年9月23日
    0
  • Android——谷歌官方下拉刷新控件SwipeRefreshLayout「建议收藏」

    Android——谷歌官方下拉刷新控件SwipeRefreshLayout「建议收藏」转自:http://blog.csdn.net/zouzhigang96/article/details/50476402前言: 如今谷歌推出了更官方的下拉刷新控件,这无疑是对安卓开发人员来说是个好消息,很方便的使用这个SwipeRefreshLayout控件实现下拉刷新功能。Android4.0以下的版本需要用到android-support-v4.jar包才能用到 andr

    2022年6月25日
    28
  • (转)SAP 将smartforms的报表转成PDF

    (转)SAP 将smartforms的报表转成PDF(转)SAP 将smartforms的报表转成PDF

    2022年4月20日
    43
  • JSON字符串转换为Map

    JSON字符串转换为Map转自:http://blog.csdn.net/zknxx/article/details/52281220本文是利用阿里巴巴封装的FastJSON来转换json字符串的。例子如下:packagecom.zkn.newlearn.json;importcom.alibaba.fastjson.JSON;importcom.alibaba.fastjson.JSON…

    2022年6月21日
    20
  • C3P0 连接池配置详解

    C3P0 连接池配置详解c3p0-config>   default-config>      property name=”acquireIncrement”>3property>        property name=”acquireRetryAttempts”>30property>        property name=”acquireRetryDelay”>1000p

    2022年5月2日
    35
  • 详述Java中sort排序函数

    详述Java中sort排序函数手写一个排序算法的效率是很慢的,当然这也不利于我们在比赛或者工程中的实战,如今几乎每个语言的标准库中都有排序算法,今天让我来给大家讲解一下Java语言中的sort排序Collections类中的sort方法可以实现List接口的集合进行排序降序排序Java中降序排序有俩种方法(和c++很类似,可以看我这篇博客):c++sort排序实现Comparator接口的复写compare()方法排序原理通常,在看有关算法书籍的时候,会发现都说有关数组的排序算法,而且使用的都是随机访问,但是

    2022年7月12日
    14

发表回复

您的邮箱地址不会被公开。 必填项已用 * 标注

关注全栈程序员社区公众号