Composer Require 'package' 抛出 OpenSSL 错误

Elb*_*rto 4 php ssl-certificate composer-php packagist

这个问题似乎很常见,我已经浏览了很多与之相关的帖子,但没有任何效果,我快要疯了。奇怪的是,几周前它工作得很好,几个月以来我没有安装任何新东西......

\n\n

设置 :

\n\n
    \n
  • PHP 7.1.9
  • \n
  • 旺普服务器3.1.0
  • \n
  • 阿帕奇2.4.27
  • \n
  • 作曲家 1.6.5(最新)
  • \n
  • 我不在代理后面且没有防火墙
  • \n
  • Windows 10
  • \n
\n\n

什么有效:

\n\n
    \n
  • 作曲家自我更新
  • \n
\n\n

什么不起作用:

\n\n
    \n
  • 安装包

  • \n
  • 我无法使用 firefox 61.0.1(64 位)访问https://packagist.org/(不安全连接:MOZILLA_PKIX_ERROR_SELF_SIGNED_CERT

  • \n
\n\n

我在作曲家要求时遇到的错误:

\n\n
[Composer\\Downloader\\TransportException]\nThe "https://packagist.org/packages.json" file could not be downloaded: SSL operation failed with code 1. OpenSSL Error messages:\nerror:14090086:SSL routines:ssl3_get_server_certificate:certificate verify failed\nFailed to enable crypto\nfailed to open stream: operation failed          \n
Run Code Online (Sandbox Code Playgroud)\n\n

php -r “var_dump(openssl_get_cert_locations());” 返回这个:

\n\n
array(8) {\n  ["default_cert_file"]=>\n  string(25) "c:/usr/local/ssl/cert.pem"\n  ["default_cert_file_env"]=>\n  string(13) "SSL_CERT_FILE"\n  ["default_cert_dir"]=>\n  string(22) "c:/usr/local/ssl/certs"\n  ["default_cert_dir_env"]=>\n  string(12) "SSL_CERT_DIR"\n  ["default_private_dir"]=>\n  string(24) "c:/usr/local/ssl/private"\n  ["default_default_cert_area"]=>\n  string(16) "c:/usr/local/ssl"\n  ["ini_cafile"]=>\n  string(51) "C:/wamp64/bin/php/php7.1.9/extras/ssl/ca-bundle.crt"\n  ["ini_capath"]=>\n  string(0) ""\n}\n
Run Code Online (Sandbox Code Playgroud)\n\n

我已经下载了 ca-bundle.crt 并将其添加到我的 php.ini 文件中:

\n\n
curl.cainfo=C:/wamp64/bin/php/php7.1.9/extras/ssl/ca-bundle.crt    \nopenssl.cafile=C:/wamp64/bin/php/php7.1.9/extras/ssl/ca-bundle.crt\n
Run Code Online (Sandbox Code Playgroud)\n\n

作曲家诊断返回此:

\n\n
Checking composer.json: OK\nChecking platform settings: OK\nChecking git settings: OK\nChecking http connectivity to packagist: WARNING\n[Composer\\Downloader\\TransportException] The "http://packagist.org/packages.json" file could not be downloaded (HTTP/1.1 404 Not Found)\nChecking https connectivity to packagist: WARNING\n[Composer\\Downloader\\TransportException] The "https://packagist.org/packages.json" file could not be downloaded: SSL operation failed with code 1. OpenSSL Error messages:\nerror:14090086:SSL routines:ssl3_get_server_certificate:certificate verify failed\nFailed to enable crypto\nfailed to open stream: operation failed\nChecking github.com rate limit: OK\nChecking disk free space: OK\nChecking pubkeys: OK\nChecking composer version: OK\nComposer version: 1.6.5\nPHP version: 7.1.9\nPHP binary path: C:\\wamp64\\bin\\php\\php7.1.9\\php.exe\n
Run Code Online (Sandbox Code Playgroud)\n\n

作曲家秀-p -vvv | grep ssl 返回:

\n\n
Reading ./composer.json\nLoading config file ./composer.json\nChecked CA file C:\\wamp64\\bin\\php\\php7.1.9\\extras\\ssl\\ca-bundle.crt: valid\nExecuting command (C:\\wamp64\\www\\projectName): git branch --no-color --no-abbrev -v\nFailed to initialize global composer: Composer could not find the config file: C:/Users/********/AppData/Roaming/Composer/composer.json\nTo initialize a project, please create a composer.json file as described in the https://getcomposer.org/ "Getting Started" section\nReading C:\\wamp64\\www\\projectName/vendor/composer/installed.json\nLoading plugin PackageVersions\\Installer\nLoading plugin Symfony\\Flex\\Flex\nComposer >=1.7 not found, downloads will happen in sequence\nRunning 1.6.5 (2018-05-04 11:44:59) with PHP 7.1.9 on Windows NT / 10.0\next-openssl         7.1.9    The openssl PHP extension\nlib-openssl         1.0.2.11 OpenSSL 1.0.2k  26 Jan 2017\n
Run Code Online (Sandbox Code Playgroud)\n\n

php --ini :

\n\n
Configuration File (php.ini) Path: C:\\WINDOWS\nLoaded Configuration File:         C:\\wamp64\\bin\\php\\php7.1.9\\php.ini\nScan for additional .ini files in: (none)\nAdditional .ini files parsed:      (none)\n
Run Code Online (Sandbox Code Playgroud)\n\n

编辑 1
\n- 尝试清空缓存
\n- 其他网络浏览器(chrome、edge)但不起作用
\n- 同一网络上的另一台计算机 --> 它可以工作

\n\n

编辑2
\n- 创建了一个新的 Windows 用户,但不起作用

\n\n

编辑 3
\n- 我可以按照@kallosz的建议访问https://repo.packagist.org/
\n- Curl 给了我这个:

\n\n
curl -vvv https://packagist.org/\n*   Trying 144.217.203.53...\n* TCP_NODELAY set\n* Connected to packagist.org (144.217.203.53) port 443 (#0)\n* schannel: SSL/TLS connection with packagist.org port 443 (step 1/3)\n* schannel: checking server certificate revocation\n* schannel: sending initial handshake data: sending 178 bytes...\n* schannel: sent initial handshake data: sent 178 bytes\n* schannel: SSL/TLS connection with packagist.org port 443 (step 2/3)\n* schannel: failed to receive handshake, need more data\n* schannel: SSL/TLS connection with packagist.org port 443 (step 2/3)\n* schannel: encrypted data got 1462\n* schannel: encrypted data buffer: offset 1462 length 4096\n* schannel: next InitializeSecurityContext failed: SEC_E_UNTRUSTED_ROOT (0x80090325) - La cha\xc3\xaene de certificats a \xc3\xa9t\xc3\xa9 fournie par une autorit\xc3\xa9 qui n\'est pas approuv\xc3\xa9e.\n* Closing connection 0\n* schannel: shutting down SSL/TLS connection with packagist.org port 443\n* schannel: clear security context handle\ncurl: (77) schannel: next InitializeSecurityContext failed: SEC_E_UNTRUSTED_ROOT (0x80090325)\n
Run Code Online (Sandbox Code Playgroud)\n