首页> 实战笔录 >PHP开发笔记 >Fastadmin Fastadmin

cURL error 60: SSL certificate problem: unable to get local issuer certificate 解决方法

作者:小萝卜 2023-07-08 浏览 330

简介fastadmin开发小程序登录功能报错:cURL error 60: SSL certificate problem: unable to get local issuer certificate (see https://curl.haxx.se/libcurl/c/libcurl-errors.html) for https://api.weixin.qq.com/cgi-bin/token?grant_type=client_credential&appid=wx72e541ff2238317d6&secret=81b90qe12q2d3sdf2257e20a79b549fa

fastadmin开发小程序登录功能报错:

cURL error 60: SSL certificate problem: unable to get local issuer certificate (see https://curl.haxx.se/libcurl/c/libcurl-errors.html) for https://api.weixin.qq.com/cgi-bin/token?grant_type=client_credential&appid=wx72e541ff2238317d6&secret=81b90qe12q2d3sdf2257e20a79b549fa

原因:

是使用curl时获取SSL证书报错:无法获得本地颁发者证书;

解决方法:

1、下载cacert

下载地址:https://curl.haxx.se/ca/cacert.pem

2、修改 php.ini , 并重启

在php.ini中找到curl.cainfo改为文件的绝对路径如:

curl.cainfo =E:\phpstudy\PHPTutorial\php\php-7.2.1-nts\cacert.pem

注意事项:

需要开启 php_curl、php_openssl 扩展;

如果是用php curl() 方法的话。可以 清除ssl证书校验:

<?php
// 创建curl资源
$ch = curl_init(); 
// 设置url
curl_setopt($ch, CURLOPT_URL, "https://www.test.com"); 
// 将Transfer作为字符串返回
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
// 关闭SSL验证
curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, 0);
curl_setopt($ch, CURLOPT_SSL_VERIFYHOST, 0);
// 执行并输出
$output = curl_exec($ch); 
// 查看错误
$error = curl_error($ch);
echo $error;
// 释放curl资源
curl_close($ch);

 

很赞哦! (0)

文章评论

    高端网站建设