编程 解决php中出现cURL error 60: SSL certificate problem: unable to get local issuer certificate

2024-11-18 19:18:40 +0800 CST views 5708

突然莫名出现如下错误

cURL error 60: SSL certificate problem: unable to get local issuer certificate (see https://curl.haxx.se/libcurl/c/libcurl-errors.html)

#解决方式1:

1、下载cacert

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

2、修改 php.ini , 并重启

在php.ini中找到curl.cainfo改为文件的绝对路径如:curl.cainfo =H:\myphp\php\php-7.1.30-nts\cacert.pem


#解决方式2

<?php
// 创建curl资源
$ch = curl_init(); 
// 设置url
curl_setopt($ch, CURLOPT_URL, "https://www.baidu.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);
复制全文 生成海报 编程 网络 PHP 错误处理

推荐文章

html一个全屏背景视频
2024-11-18 00:48:20 +0800 CST
如何在Rust中使用UUID?
2024-11-19 06:10:59 +0800 CST
跟着 IP 地址,我能找到你家不?
2024-11-18 12:12:54 +0800 CST
PHP如何进行MySQL数据备份?
2024-11-18 20:40:25 +0800 CST
PyMySQL - Python中非常有用的库
2024-11-18 14:43:28 +0800 CST
Vue3的虚拟DOM是如何提高性能的?
2024-11-18 22:12:20 +0800 CST
MySQL设置和开启慢查询
2024-11-19 03:09:43 +0800 CST
Vue3中如何进行错误处理?
2024-11-18 05:17:47 +0800 CST
程序员茄子在线接单