php 从 packagist 更新时 Composer 更新失败
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/27206719/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
Composer update fails while updating from packagist
提问by yuklia
While executing composer install/update I have got the following error from openssl:
在执行 composer install/update 时,我从 openssl 收到以下错误:
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 https://packagist.orgcould not be fully loaded, package information was loaded from the local cache and may be out of date
无法下载“ https://packagist.org/packages.json”文件:SSL 操作失败,代码为 1。OpenSSL 错误消息:错误:14090086:SSL 例程:SSL3_GET_SERVER_CERTIFICATE:证书验证失败未能启用加密无法打开流:操作失败 https://packagist.org无法完全加载,包信息已从本地缓存加载,可能已过期
I am using:
我在用:
- PHP 5.6.3 (cli) (built: Nov 17 2014 15:16:53)
- XAMPP stack 5.6.3-0
- ubuntu 14.04
- PHP 5.6.3 (cli)(构建时间:2014 年 11 月 17 日 15:16:53)
- XAMPP 堆栈 5.6.3-0
- Ubuntu 14.04
composer diag shows:
作曲家诊断显示:
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]
The "https://getcomposer.org/version" 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
[作曲\下载\ TransportException]
的“ https://getcomposer.org/version”文件无法下载:SSL操作失败,代码1. OpenSSL的错误信息:
错误:14090086:SSL例程:SSL3_GET_SERVER_CERTIFICATE:证书验证失败
失败启用加密
无法打开流:操作失败
php -r 'var_dump(openssl_get_cert_locations());' shows:
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) ""
}
For php 5.5.19 everything is Ok.
对于 php 5.5.19,一切正常。
回答by Manuel Ochoa
I found a solution to this
我找到了解决方案
I'm running:
FreeBSD 10.1
Apache2.4
PHP 5.6.3
我正在运行:
FreeBSD 10.1
Apache2.4
PHP 5.6.3
To find the CA file I ran this command
为了找到 CA 文件,我运行了这个命令
> locate cacert.pem
> locate cacert.pem
Result was:
/usr/local/lib/perl5/site_perl/5.16/Mozilla/CA/cacert.pem
结果是:
/usr/local/lib/perl5/site_perl/5.16/Mozilla/CA/cacert.pem
Then open the php.ini file and
change this:
然后打开 php.ini 文件并
更改:
;openssl.cafile=
;openssl.cafile=
To this:
对此:
openssl.cafile=/usr/local/lib/perl5/site_perl/5.16/Mozilla/CA/cacert.pem
openssl.cafile=/usr/local/lib/perl5/site_perl/5.16/Mozilla/CA/cacert.pem
Note: This directive is only available on php 5.6.x
注意:此指令仅适用于 php 5.6.x
Then restart Apache
然后重启Apache
回答by kipzes
I solved the problem with the SSL error by adding the SSL certificate to the XAMPP certificates folder.
我通过将 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
Don't forget to restart your apache!
不要忘记重新启动您的apache!
回答by Neel
I am using Mac OS Sierra and when I was trying to update the composer using the command /usr/local/bin/composer self-update
I kept getting the error:
我正在使用 Mac OS Sierra,当我尝试使用命令更新作曲家时,/usr/local/bin/composer self-update
我不断收到错误消息:
[Composer\Downloader\TransportException]
The "https://getcomposer.org/version" file could not be downloaded: SSL operation failed with co
de 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
I fixed it following these steps:
我按照以下步骤修复了它:
1) Create the local database using the command:
1)使用以下命令创建本地数据库:
sudo launchctl load -w /System/Library/LaunchDaemons/com.apple.locate.plist
2) Locate the cert file:
2)找到证书文件:
locate cacert.pem
3) Check the location of the php.ini file:
3)检查php.ini文件的位置:
php --ini
4) If the 'Loaded Configuration File' for php.ini
file is showing as (none)
, copy the file /etc/php.ini.default
to /etc/php.ini
:
4) 如果文件的“加载的配置文件”php.ini
显示为(none)
,请将文件复制/etc/php.ini.default
到/etc/php.ini
:
sudo cp /etc/php.ini.default /etc/php.ini
5) Open the php.ini
file and edit the ;openssl.cafile=
line by uncommenting it and appending the link to the cert file location:
5)打开php.ini
文件并;openssl.cafile=
通过取消注释并将链接附加到证书文件位置来编辑该 行:
openssl.cafile=/Users/me/.composer/cacert.pem
Thats it. Now, when you run the composer update, it will work fine.
就是这样。现在,当您运行 Composer 更新时,它将正常工作。
回答by phoenix
Adding openssl.cafile to php.ini worked for me too. Instead of looking for the cert file, I downloaded it directly:
将 openssl.cafile 添加到 php.ini 也对我有用。我没有寻找cert文件,而是直接下载了它:
curl http://curl.haxx.se/ca/cacert.pem> cacert.pem
curl http://curl.haxx.se/ca/cacert.pem> cacert.pem
and then just pointed openssl.cafile setting to it.
然后只是将 openssl.cafile 设置指向它。
回答by sim
composer clearcache
This worked for me when I get error :
当我收到错误时,这对我有用:
https://packagist.orgcould not be fully loaded, package information was loaded from the local cache and may be out of date
https://packagist.org无法完全加载,包信息是从本地缓存加载的,可能已过期
回答by Praveen Govind
I ran into the same exact issue on Windows even after adding valid latest certificate downloaded. I'm running composer behind proxy, So i've to add environment variables http_proxy and https_proxy.
即使添加了下载的有效最新证书,我在 Windows 上也遇到了同样的问题。我在代理后面运行作曲家,所以我必须添加环境变量 http_proxy 和 https_proxy。
My environment: PHP 5.6.33 Windows 7 64 bit Composer version 1.6.3 2018-01-31 16:28:17
我的环境:PHP 5.6.33 Windows 7 64 位 Composer 版本 1.6.3 2018-01-31 16:28:17
I downloaded latest certificates CA Bundleand updated following paths in my php.ini still didn't work.
我下载了最新的证书CA Bundle并更新了我的 php.ini 中的以下路径仍然不起作用。
curl.cainfo = C:\Certificates\ca-bundle.crt
openssl.cafile= C:\Certificates\ca-bundle.crt
openssl.capath=C:\Certificates
Then did following steps
然后做了以下步骤
1) Open chrome browser and navigate https://packagist.org/
1) 打开 Chrome 浏览器并导航https://packagist.org/
2) Click on the little Secure Lock icon
2) 点击小安全锁图标
3) Click on Certificates Valid
3) 点击证书有效
4)Open Certificate Path tab and you will see the following path levels
4)打开证书路径选项卡,您将看到以下路径级别
5) Need to export the certificate for both 1&2 marked in the image
5) 需要导出图中标记的1&2的证书
6) To export certificate, click on view Certificate, Got to Details Tab and click on Copy to file
6) 要导出证书,请单击查看证书、转到详细信息选项卡并单击复制到文件
7)choose BASE 64 encoding
7)选择BASE 64编码
8) click on Next and save that file to a location, Do this for No. (2) shown in setp 4
8)单击下一步并将该文件保存到一个位置,对第(2)号执行此操作,如setp 4所示
9) Open the .cer file and copy the content to the end of .crt file which you used to configure in php.ini
9)打开.cer文件,将内容复制到你在php.ini中配置的.crt文件末尾
Then try running comport install - It's worked for me
然后尝试运行 comport install - 它对我有用
Process should be same if you see composer throwing ssl error when accessing sites over proxy.
如果您看到 Composer 在通过代理访问站点时抛出 ssl 错误,则过程应该相同。
回答by shengji yin
1.
1.
php -r "print_r(openssl_get_cert_locations());"
array(8) {
["default_cert_file"]=>
string(31) "/usr/local/etc/openssl/cert.pem"
...
}
2.vim php.ini
2.vim php.ini
[openssl]
openssl.cafile=/usr/local/etc/openssl/cert.pem
回答by user5030739
On the mac with XAMPP:
在带有 XAMPP 的 Mac 上:
cd /Applications/XAMPP/xamppfiles/share/openssl
sudo curl -O -k http://curl.haxx.se/ca/cacert.pem
sudo mv cacert.pem cert.pem
Stop and Restart Apache
停止并重新启动 Apache
回答by Amanuel Nega
First: Check certificate file location which will be in default_cert_file
key, you will found it in openssl_get_cert_locations()
its a php openssl function. You can run it as follows:
首先:检查default_cert_file
密钥中的证书文件位置,您将在openssl_get_cert_locations()
其 php openssl 函数中找到它。您可以按如下方式运行它:
$ php -r "print_r(openssl_get_cert_locations());"
Output in my system
在我的系统中输出
Array
(
[default_cert_file] => /opt/lampp/share/openssl/cert.pem
[default_cert_file_env] => SSL_CERT_FILE
[default_cert_dir] => /opt/lampp/share/openssl/certs
[default_cert_dir_env] => SSL_CERT_DIR
[default_private_dir] => /opt/lampp/share/openssl/private
[default_default_cert_area] => /opt/lampp/share/openssl
[ini_cafile] =>
[ini_capath] =>
)
Second: Download http://curl.haxx.se/ca/cacert.pem:
第二:下载http://curl.haxx.se/ca/cacert.pem:
$ wget http://curl.haxx.se/ca/cacert.pem
Third: Copy certificate.pem
file into default_cert_file
location:
第三:将certificate.pem
文件复制到default_cert_file
位置:
$ sudo mv cacert.pem /opt/lampp/share/openssl/cert.pem
回答by WJN LLC
locate cacert.pem
vi /usr/local/lib/php.ini
#add this
openssl.cafile=/usr/local/share/perl5/Mozilla/CA/cacert.pem
# press esc then type
:wq #enter
curl -sS https://getcomposer.org/installer | php -- —version=1.0.0-alpha10
mv composer.phar /usr/local/bin/composer
alias composer='/usr/local/bin/composer'
composer -V
php /usr/local/bin/composer global self-update
cd .composer/
composer init