使用composer安装插件时,有时会报类似以下的错误:
Unable to locate a valid CA certificate file. You must set a valid 'cafile' option.
A valid CA certificate file is required for SSL/TLS protection.
You can disable this error, at your own risk, by setting the 'disable-tls' option to true.
Unable to locate a valid CA certificate file. You must set a valid 'cafile' option.
A valid CA certificate file is required for SSL/TLS protection.
You can disable this error, at your own risk, by setting the 'disable-tls' option to true.
原因一般是本地证书过期了,或者composer根本就没找到你的证书在哪。
查看本地证书的位置
输入命令
php -r 'var_dump(openssl_get_cert_locations());'
找到有.pem的哪一项,就是证书所在的目录,如:/Applications/MAMP/Library/OpenSSL/cert.pem
设置composer
如果证书已过期,需下载新的证书替换旧的证书
输入以下命令
composer config --global cafile '/Applications/MAMP/Library/OpenSSL/cert.pem'
网友评论