将自签名证书添加到系统CA包或通过COMPOSER_CAFILE指定路径,可让Composer信任该证书。1. 将.crt文件复制到/usr/local/share/ca-certificates/并执行update-ca-certificates;2. 在php.ini中设置openssl.cafile和curl.cainfo指向证书;3. 设置环境变量COMPOSER_CAFILE="/path/to/your-ca.crt";4. 临时禁用TLS验证(不推荐生产使用)。优先推荐前三种方法以保障安全。

让 Composer 信任自签名 SSL 证书,关键在于将你的证书添加到 PHP 的可信证书列表中,或配置 Composer 使用指定的证书路径。以下是几种实用方法:
操作步骤:
sudo cp your-ca.crt /usr/local/share/ca-certificates/ sudo update-ca-certificates
修改 php.ini 文件:
openssl.cafile="/path/to/your-ca.crt" curl.cainfo="/path/to/your-ca.crt"
使用方式:
export COMPOSER_CAFILE="/path/to/your-ca.crt" composer install
composer config --global disable-tls true composer config --global secure-http false
composer config --global disable-tls false composer config --global secure-http true
基本上就这些。最安全的做法是把证书加入系统或通过 COMPOSER_CAFILE 指定,避免全局关闭 TLS 验证。
每个人都需要一台速度更快、更稳定的 PC。随着时间的推移,垃圾文件、旧注册表数据和不必要的后台进程会占用资源并降低性能。幸运的是,许多工具可以让 Windows 保持平稳运行。
Copyright 2014-2025 https://www.php.cn/ All Rights Reserved | php.cn | 湘ICP备2023035733号