下载 https://repo.packagist.org 时出现 curl 错误 60 Ubuntu 上的证书问题?

curl error 60 while downloading https://repo.packagist.org Certificate issue on Ubuntu?

我已经根据 https://getcomposer.org/download/

在全局(和本地 - 仅用于测试)安装了 composer

然后,我正在尝试 composer create-project laravel/laravel,但我收到一个错误:

composer create-project laravel/laravel Creating a "laravel/laravel" project at "./laravel"

[Composer\Downloader\TransportException]
curl error 60 while downloading https://repo.packagist.org/packages.json: SSL: no alternative certificate subject name matches target host name 'repo.packagist.org'

所以我尝试了这个包括答案:

curl.cainfo = "/etc/ssl/certs/cacert.pem"
openssl.cafile = "/etc/ssl/certs/cacert.pem"
openssl.capath = "/etc/ssl/certs/cacert.pem"

进入 7.4 CLI php.ini:php --ini

Configuration File (php.ini) Path: /etc/php/7.4/cli
Loaded Configuration File: /etc/php/7.4/cli/php.ini
Scan for additional .ini files in: /etc/php/7.4/cli/conf.d
Additional .ini files parsed: /etc/php/7.4/cli/conf.d/10-mysqlnd.ini,
...

哪个好像还行? php -i | grep -i openssl

SSL Version => OpenSSL/1.1.1f libSSH Version => libssh/0.9.3/openssl/zlib openssl OpenSSL support => enabled OpenSSL Library Version => OpenSSL 1.1.1f 31 Mar 2020 OpenSSL Header Version => OpenSSL 1.1.1f 31 Mar 2020 Openssl default config => /usr/lib/ssl/openssl.cnf openssl.cafile => /home/hpn/Software/cacert.pem => /home/hpn/Software/cacert.pem
openssl.capath => /home/hpn/Software/cacert.pem => /home/hpn/Software/cacert.pem
Native OpenSSL support => enabled

我什至已经尝试过了

composer config disable-tls true
composer config secure-http false

但错误依旧。

然后我找到了这个:http://manpages.ubuntu.com/manpages/bionic/man8/update-ca-certificates.8.html 并做了:sudo update-ca-certificates - 仍然有同样的错误。

我遇到了和你一样的问题:下载证书和更新 php.ini 值没有用。

我只是升级了我所有的服务器包sudo apt-get update && sudo apt-get upgrade,问题就解决了。不过,我还没有确定确切的 package/packages 需要更新什么。

我在 /etc/hosts 文件中设置了静态 IP。 在我评论了那个之后,事情按预期进行了。

抱歉让您感到困惑 - 也许它在未来仍会对某人有所帮助。