Composer安装时发生SSL错误

igsr9ssn  于 2023-08-06  发布在  其他
关注(0)|答案(5)|浏览(171)

在安装Composer到XAMPP时,我遇到了一些错误。我的系统操作系统是Windows 7,我如何解决这个问题并安装Composer?
下载失败:file_get_contents():SSL操作失败,代码为% 1。OpenSSL错误消息:错误:14090086:SSL例程:SSL3_GET_SERVER_CERTIFICATE:证书验证失败file_get_contents():无法启用加密file_get_contents(https://getcomposer.org/composer.phar.sig):无法打开流:操作失败下载失败:file_get_contents():SSL操作失败,代码为% 1。OpenSSL错误消息:错误:14090086:SSL例程:SSL3_GET_SERVER_CERTIFICATE:证书验证失败file_get_contents():无法启用加密文件_get_contents(https://getcomposer.org/composer.phar.sig):无法打开流:操作失败

3zwjbxry

3zwjbxry1#

确保您在php.ini中配置了ca证书的路径:

curl.cainfo=/full/path/to/ssl/certs/ca-bundle.crt
openssl.cafile=/full/path/to/ssl/certs/ca-bundle.crt

字符串
如果您没有ca证书包,请下载它:
https://raw.githubusercontent.com/bagder/ca-bundle/master/ca-bundle.crt
安装Composer(不使用cURL):
php -r "readfile('https://getcomposer.org/installer');" | php
或者,安装Composer(使用cURL):

curl -sS https://getcomposer.org/installer | php


(If如果没有解决问题,只需通过浏览器下载Composer PHAR。
https://getcomposer.org/composer.phar
但是,在获取包时,您将再次遇到这个问题,直到您修复证书问题。)

vlurs2pr

vlurs2pr2#

这正是我面临的问题。在我的Windows 7机器上安装Composer安装程序时,我收到以下错误:

The "https://getcomposer.org/versions" 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

字符串
尝试了这个:

$ curl -sS https://getcomposer.org/installer | php
stdin is not a tty
curl: (60) SSL certificate problem: self signed certificate in certificate chain
More details here: https://curl.haxx.se/docs/sslcerts.html

curl performs SSL certificate verification by default, using a "bundle"
 of Certificate Authority (CA) public keys (CA certs). If the default
 bundle file isn't adequate, you can specify an alternate file
 using the --cacert option.
If this HTTPS server uses a certificate signed by a CA represented in
 the bundle, the certificate verification probably failed due to a
 problem with the certificate (it might be expired, or the name might
 not match the domain name in the URL).
If you'd like to turn off curl's verification of the certificate, use
 the -k (or --insecure) option.


还有这个

$ ping getcomposer.org

Pinging getcomposer.org [87.98.253.108] with 32 bytes of data:
Reply from 87.98.253.108: bytes=32 time=137ms TTL=47
Reply from 87.98.253.108: bytes=32 time=127ms TTL=47
Reply from 87.98.253.108: bytes=32 time=127ms TTL=47
Reply from 87.98.253.108: bytes=32 time=127ms TTL=47

Ping statistics for 87.98.253.108:
    Packets: Sent = 4, Received = 4, Lost = 0 (0% loss),
Approximate round trip times in milli-seconds:
    Minimum = 127ms, Maximum = 137ms, Average = 129ms


我的PHP版本是:

$ php -v
PHP 5.5.37 (cli) (built: Jun 22 2016 16:14:46)
Copyright (c) 1997-2015 The PHP Group
Zend Engine v2.5.0, Copyright (c) 1998-2015 Zend Technologies
    with Zend OPcache v7.0.6-dev, Copyright (c) 1999-2015, by Zend Technologies


我已经在我的php.ini中启用了以下列表:

extension=php_curl.dll
extension=php_openssl.dll
curl.cainfo="C:/xampp/php/extras/certs/cacert.pem"
openssl.cafile="C:/xampp/php/extras/certs/cacert.pem"


我从https://curl.haxx.se/ca/cacert.pem下载了cacert.pem
我错过了添加代理设置,而安装,当添加它的工作就像魅力!:)

http://username:password@your_proxy:your_port

jjjwad0x

jjjwad0x3#

我在Windows上更改PHP版本时遇到了同样的问题。希望这能帮助到别人。php.ini没有正确的扩展名,我不得不取消注解:

extension_dir = "ext"
extension=openssl

字符串

9lowa7mx

9lowa7mx4#

检查你的php的php.ini为我我在mac上使用ampps,只是改变了它:curl.cainfo =/Applications/AMPPS/ca-bundle.crt openssl.cafile =/Applications/AMPPS/ca-bundle.crt
更新php.ini后,需要重新启动Apache
您可以在这里下载ca-bundle.cer https://raw.githubusercontent.com/bagder/ca-bundle/master/ca-bundle.crt并将其重命名为ca-bundle.crt。
在更新php.ini x1c 0d1x之前和之后检查附件供您参考

uqjltbpv

uqjltbpv5#

我通过在安装命令和“composer-setup.php”文件中替换“http”上的所有“https”来解决这个问题。

vim composer-setup.php
:%s/https/http

字符串

相关问题