在使用代理程式的 Windows 7 上安裝 Composer 時出現 SSL 驗證失敗錯誤

在使用代理程式的 Windows 7 上安裝 Composer 時出現 SSL 驗證失敗錯誤

我的錯誤是,每當我嘗試使用 GUI 和命令列安裝 Composer 時,我都會收到相同的錯誤,SSL 驗證失敗,因此無法透過我的代理連接到 HTTP。我在一台在代理程式後面運行 XAMPP 的 Windows 7 電腦上。

首先,我已經對此錯誤進行了研究,並嘗試了其他帖子上的所有解決方案,我想知道我錯過了什麼。

我嘗試過的事情:

  • 目前使用 XAMPP for apache,我下載並安裝了最新版本以及一些先前的版本
  • 我重新下載了curl-ca-bundle.crt並更新了我的\xampp\apache\bin\curl-ca-bundle.crt以反映最新版本(XAMPP附帶的版本和我使用的版本之間大約有20kb的差異)下載)。
  • 我手動下載了 getcomposer.org 的憑證並將其附加到我的curl-ca-bundle.crt 的末尾。 (是的,我確信這是 PHP/Composer 用來安裝的檔案)
  • 當我嘗試透過命令列安裝它時,我收到一條錯誤訊息,指出沒有這樣的主機。我發現這個問題是由於未設定 HTTP/HTTPS_PROXY url 造成的。我打開它們,然後得到與通過 GUI 相同的錯誤(如下所示)
  • 然後,當我透過Composer 的網站並下載.exe 進行安裝時,在安裝程式中,我可以選擇指定代理程式(我這樣做了)以擺脫no sush 主機,在指定代理程式後,我現在遇到了完全相同的錯誤作為命令行。
  • 禁用 Composer 的 SSL/TLS。但嘗試使用 https 聯絡任何網站時仍然失敗。

圖形使用者介面:

Composer 安裝程式腳本未成功 [退出代碼 1]。

OpenSSL 失敗並出現「憑證驗證失敗」錯誤。這表示您系統上的憑證授權單位文件有問題,該文件可能已過期。

憑證位置 [來自 openssl.cafile ini 設定]:\xampp\apache\bin\curl-ca-bundle.crt

命令列 PHP 使用的 php.ini 是:C:\xampp\php\php.ini

腳本輸出:“https://getcomposer.org/versions「無法下載檔案:SSL 操作失敗,程式碼為 1。OpenSSL 錯誤訊息:錯誤:1416F086:SSL 程式:tls_process_server_certificate:憑證驗證失敗無法開啟流:無法透過代理連接到 HTTPS 伺服器

命令線:

C:\Users\S0077500\Desktop\Laravel\Attempt 7>php composer.phar diagnose
You are running Composer with SSL/TLS protection disabled.
Checking platform settings: OK
Checking git settings: OK
Checking http connectivity to packagist: OK
Checking https connectivity to packagist: WARNING
[Composer\Downloader\TransportException] The "https://repo.packagist.org/package
s.json" file could not be downloaded: SSL operation failed with code 1. OpenSSL
Error messages:
error:1416F086:SSL routines:tls_process_server_certificate:certificate verify fa
iled
failed to open stream: Cannot connect to HTTPS server through proxy
Composer is configured to disable SSL/TLS protection. This will leave remote HTT
PS requests vulnerable to Man-In-The-Middle attacks.
Checking HTTP proxy: FAIL
[Composer\Downloader\TransportException] The "https://repo.packagist.org/package
s.json" file could not be downloaded: SSL operation failed with code 1. OpenSSL
Error messages:
error:1416F086:SSL routines:tls_process_server_certificate:certificate verify fa
iled
failed to open stream: Cannot connect to HTTPS server through proxy
Checking HTTP proxy support for request_fulluri: OK
Checking HTTPS proxy support for request_fulluri: Unable to assess the situation
, maybe github is down (The "https://api.github.com/repos/Seldaek/jsonlint/zipba
ll/1.0.0" file could not be downloaded: SSL operation failed with code 1. OpenSS
L Error messages:
error:1416F086:SSL routines:tls_process_server_certificate:certificate verify fa
iled
failed to open stream: Cannot connect to HTTPS server through proxy)
Checking github.com rate limit: FAIL
[Composer\Downloader\TransportException] The "https://api.github.com/rate_limit"
 file could not be downloaded: SSL operation failed with code 1. OpenSSL Error m
essages:
error:1416F086:SSL routines:tls_process_server_certificate:certificate verify fa
iled
failed to open stream: Cannot connect to HTTPS server through proxy
Checking disk free space: OK
Checking pubkeys: FAIL
Missing pubkey for tags verification
Missing pubkey for dev verification
Run composer self-update --update-keys to set them up
Checking composer version:

  [Composer\Downloader\TransportException]
  The "https://getcomposer.org/versions" file could not be downloaded: SSL op
  eration failed with code 1. OpenSSL Error messages:
  error:1416F086:SSL routines:tls_process_server_certificate:certificate veri
  fy failed
  failed to open stream: Cannot connect to HTTPS server through proxy


diagnose


C:\Users\S0077500\Desktop\Laravel\Attempt 7>

答案1

我有 Windows 10 和 xampp 3.0.12 (php5.3)。我無法安裝作曲家。我嘗試了以下步驟,它對我有用。

  1. 從下載安裝程式腳本https://getcomposer.org/installer
  2. 將其儲存在名為 的檔案中composer-setup.php
  3. 在您最喜歡的編輯器中開啟composer-setup.php
  4. 將所有 HTTPS 替換為 HTTP 並儲存檔案。
  5. 在命令提示字元下執行以下 3 個步驟:

    php -r "if (hash_file('sha384', 'composer-setup.php') === 'a5c698ffe4b8e849a443b120cd5ba38043260d5c4023dbf93e1558871f1f07f58274fc6f4c93bcfd858c6bd0775cd8d1') { echo 'Installer verified'; } else { echo 'Installer corrupt'; unlink('composer-setup.php'); } echo PHP_EOL;"
    
    php composer-setup.php
    
    php -r "unlink('composer-setup.php');"
    
  6. 瞧!成功安裝composer,可以運行:php composer.phar

謝謝

答案2

我有同樣的錯誤。這就是我解決問題的方法。我按照中的說明進行操作https://getcomposer.org/download/,下面的段落命令列安裝

```
php -r "copy('https://getcomposer.org/installer', 'composer-setup.php');"
php -r "if (hash_file('sha384', 'composer-setup.php') === '55ce33d7678c5a611085589f1f3ddf8b3c52d662cd01d4ba75c0ee0459970c2200a51f492d557530c71c15d8dba01eae') { echo 'Installer verified'; } else { echo 'Installer corrupt'; unlink('composer-setup.php'); } echo PHP_EOL;"
php composer-setup.php
php -r "unlink('composer-setup.php');"
```

我將行替換php composer-setup.phpphp composer-setup.php --disable-tls

無需編輯 php 腳本。

我透過查看composer-setup.php 中的程式碼得到了這個想法,我在其中找到了該選項。我應該php composer-setup.php --help更快找到相同的答案,而不需要閱讀程式碼。

相關內容