如果你的 PHP 环境证书有问题,可能会遇到报错,类似于 cURL error 60: See http://curl.haxx.se/libcurl/c/libcurl-errors.html
,请尝试按如下步骤解决:
- 到 https://curl.haxx.se/ca/cacert.pem 下载证书文件
cacert.pem
,将其保存到合适的路径下。 - 编辑
php.ini
文件,删除curl.cainfo
配置项前的分号注释符(;),值设置为保存的证书文件cacert.pem
的绝对路径。 - 重启依赖 PHP 的服务。
linux示例:
[curl]
; A default value for the CURLOPT_CAINFO option. This is required to be an
; absolute path.
curl.cainfo = /etc/pki/tls/certs/ca-bundle.crt
[openssl]
; The location of a Certificate Authority (CA) file on the local filesystem
; to use when verifying the identity of SSL/TLS peers. Most users should
; not specify a value for this directive as PHP will attempt to use the
; OS-managed cert stores in its absence. If specified, this value may still
; be overridden on a per-stream basis via the "cafile" SSL stream context
; option.
windows示例:
[curl]
; A default value for the CURLOPT_CAINFO option. This is required to be an
; absolute path.
curl.cainfo = "E:\cacert.pem"
[openssl]
; The location of a Certificate Authority (CA) file on the local filesystem
; to use when verifying the identity of SSL/TLS peers. Most users should
; not specify a value for this directive as PHP will attempt to use the
; OS-managed cert stores in its absence. If specified, this value may still
; be overridden on a per-stream basis via the "cafile" SSL stream context
; option.
;openssl.cafile=