从 packagist 更新时,Composer 更新失败

2022-08-30 13:35:49

在执行作曲家安装/更新时,我从openssl收到以下错误:

无法下载“https://packagist.org/packages.json”文件:SSL 操作失败,代码为 1。OpenSSL 错误消息:错误:14090086:SSL 例程:SSL3_GET_SERVER_CERTIFICATE:证书验证失败 无法启用加密无法打开流:操作失败 https://packagist.org 无法完全加载,包信息已从本地缓存加载,可能已过期

我正在使用:

  1. PHP 5.6.3 (cli) (建版本: Nov 17 2014 15:16:53)
  2. XAMPP 堆栈 5.6.3-0
  3. ubuntu 14.04

作曲家诊断显示:

Checking composer.json: OK
Checking platform settings: OK
Checking git settings: OK
Checking http connectivity: FAIL
[Composer\Downloader\TransportException] The "https://packagist.org/packages.json"  file  could not be downloaded: SSL operation failed with code 1. OpenSSL Error messages:
error:14090086:SSL routines:SSL3_GET_SERVER_CERTIFICATE:certificate verify failed
Failed to enable crypto
failed to open stream: operation failed
Checking disk free space: OK
Checking composer version: 

[Composer\Downloader\TransportException]
无法下载“https://getcomposer.org/version”文件:SSL 操作失败,代码为 1。OpenSSL 错误消息:错误:
14090086:SSL 例程:SSL3_GET_SERVER_CERTIFICATE:证书验证失败
启用加密
失败 无法打开流:操作失败

php -r 'var_dump(openssl_get_cert_locations());' 显示:

array(8) {
["default_cert_file"]=>
string(33) "/opt/lampp/share/openssl/cert.pem"
["default_cert_file_env"]=>
string(13) "SSL_CERT_FILE"
["default_cert_dir"]=>
string(30) "/opt/lampp/share/openssl/certs"
["default_cert_dir_env"]=>
string(12) "SSL_CERT_DIR"
["default_private_dir"]=>
string(32) "/opt/lampp/share/openssl/private"
["default_default_cert_area"]=>
string(24) "/opt/lampp/share/openssl"
["ini_cafile"]=>
string(0) ""
["ini_capath"]=>
string(0) ""
}

对于 php 5.5.19,一切都还行。


答案 1

我找到了解决这个问题的方法

我正在运行:
FreeBSD 10.1
Apache2.4
PHP 5.6.3

为了找到CA文件,我运行了此命令

> locate cacert.pem

结果是:
/usr/local/lib/perl5/site_perl/5.16/Mozilla/CA/cacert.pem

然后打开 php.ini 文件并
更改以下内容:

;openssl.cafile=

对此:

openssl.cafile=/usr/local/lib/perl5/site_perl/5.16/Mozilla/CA/cacert.pem

注意:此指令仅在 php 5.6.x 上可用

然后重新启动 Apache


答案 2

我通过将SSL证书添加到XAMPP证书文件夹解决了SSL错误的问题。

// navigate to a directory to save the certificate
cd /Downloads

// download a certificate
wget http://curl.haxx.se/ca/cacert.pem

// rename and move the file to the Xampp certificates folder
mv cacert.pem /Applications/XAMPP/xamppfiles/share/openssl/cert.pem

别忘了重启你的apache!


推荐