美文网首页
使用Composer时,报证书错误解决方法

使用Composer时,报证书错误解决方法

作者: 又起风了_ | 来源:发表于2022-10-13 11:44 被阅读0次

    使用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'
    

    相关文章

      网友评论

          本文标题:使用Composer时,报证书错误解决方法

          本文链接:https://www.haomeiwen.com/subject/wxlfzrtx.html