cURL error 60: SSL certificate problem

PHP支付代码报错:

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.mch.weixin.qq.com/pay/unifiedorder

原因是PHP配置文件中缺少cacert.pem证书配置。

解决办法

下载cacert.pem文件,下载地址:https://curl.se/docs/caextract.html

修改php.ini文件配置

需要开启curl和openssl扩展

extension=openssl
extension=curl

然后需要修改以下2个配置

配置值为cacert.pem文件的绝对路径位置

curl.cainfo = "C:/dev/php/cacert.pem"

配置值为cacert.pem文件所在文件夹的绝对路径

openssl.capath="C:/dev/php/"

重启PHP,解决问题。