无法获取本地颁发者证书
Windows版本
1.到 https://curl.haxx.se/ca/cacert.pem 下载证书文件 cacert.pem,将其保存到 PHP 安装路径下。
2.编辑 php.ini 文件,删除 curl.cainfo 配置项前的分号注释符(;),值设置为保存的证书文件 cacert.pem 的绝对路径。
3.重启依赖 PHP 的服务。
linux版本解决方案
cURL error 60: SSL certificate problem: unable to get local issuer certifica 解决
从 https://curl.haxx.se/docs/caextract.html 上下载cacert.pem
打开php.ini 搜索curl.cainfo 与 openssl.cafile,将其配置成你自己cacert.pem文件的路径
curl.cainfo=" 路径 "
openssl.cafile=“路径”
例如:
Laravel 使用GuzzleHttp请求第三方https接口报错
错误提示:
cURL error 60: Peer’s certificate issuer has been marked as not trusted by the user. (see http://curl.haxx.se/libcurl/c/libcurl-errors.html)
解决方法
$client = new Client(['verify' => false]);
解释:因为配置https协议,需要购买SSL证书,所以你需要将verify的值改为false,等后期你配置了https协议,在讲verify的值改为true。
获取 headers
(PHP 4,PHP 5,PHP 7,PHP 8)
getallheaders —提取所有HTTP请求标头
foreach (getallheaders() as $name => KaTeX parse error: Expected '}', got 'EOF' at end of input: …e) { echo "name: $value\n";}
array:9 [ "Connection" => "keep-alive" "Accept-Encoding" => "gzip, deflate, br" "Host" => "textlaravel.cc" "Postman-Token" => "b40c141e-645d-495f-8d71-f82874a642e7" "Accept" => "*/*" "User-Agent" => "PostmanRuntime/7.26.8" "Jwt" => "bearereyJ0eXAiOiJKV1QiLCJhbGciOiJIUzI1NiJ9.eyJpc3MiOiJodHRwOlwvXC90ZXh0bGFyYXZlbC5jY1wvYXBpXC9sb2dpbiIsImlhdCI6MTYxMjY3NTE0OCwiZXhwIjoxNjEyNjc4NzQ4LCJuYmYiOjE2MTI2NzUxNDgsImp0aSI6ImR5b0ZOalpzUkZVcGRqOFEiLCJzdWIiOjEsInBydiI6Ijg3ZTBhZjFlZjlmZDE1ODEyZmRlYzk3MTUzYTE0ZTBiMDQ3NTQ2YWEifQ.X2LIiNxb9fltrx3AMfajIAOrBKwhhEedePxl5kjOQw0" "Content-Length" => "" "Content-Type" => "" ]
(PHP 5 >= 5.6.0, PHP 7, PHP 8)
openssl_get_cert_locations — 检索可用的证书位置
openssl_get_cert_locations() 返回一个数组,其中包含要搜索SSL证书的可用证书位置的信息。
array:8 [ "default_cert_file" => "/usr/local/openssl/cert.pem", "default_cert_file_env" => "SSL_CERT_FILE", "default_cert_dir" => "/usr/local/openssl/certs", "default_cert_dir_env" => "SSL_CERT_DIR", "default_private_dir" => "/usr/local/openssl/private", "default_default_cert_area" => "/usr/local/openssl", "ini_cafile" => "/www/wwwroot/ext/ca-bundle.crt", "ini_capath" => "" ]
下面是guzzle官方文档
https://guzzle-cn.readthedocs.io/zh_CN/latest/quickstart.html
windows 清晰版本
解决:cURL error 60: SSL certificate problem: unable to get local issuer certificate 问题
问题原因:
此问题的出现是由于没有配置信任的服务器HTTPS验证。
默认,cURL被设为不信任任何CAs,就是说,它不信任任何服务器验证。
1、通过下面的git地址下载验证文件
https://github.com/bagder/ca-bundle/tree/e9175fec5d0c4d42de24ed6d84a06d504d5e5a09
2、把文件放到下面目录中,也就是 php.ini 同级目录的 ./extras/ssl下
3、在环境中找到, php.ini 文件
4、编辑 php.ini 文件,加入下面代码(自己的路径记得修改)
[curl] curl.cainfo="D:/phpstudy/Extensions/php/php7.3.4nts/extras/ssl/ca-bundle.crt"
最后,清除缓存刷新即可,重启PHP。
转 : https://blog.csdn.net/weiguang102/article/details/109476496
标签:certificate,get,openssl,certifica,SSL,cert,https,PHP,local From: https://www.cnblogs.com/fps2tao/p/17090009.html