Composer :SSL routines:SSL3_GET_SERVER_CERTIE

先試一試

wget http://curl.haxx.se/ca/cacert.pem

curl -sS https://getcomposer.org/installer | php -- --cafile=cacert.pem

 

安裝的php,YII2.0框架,PHP版本高於5.4,調用這個命令的時候出問題了。

composer global require "fxp/composer-asset-plugin:1.0.0"

彈出這樣的問題

 
  1.  
    Changed current directory to /home/litianci/.composer
  2.  
    ./composer.json has been updated
  3.  
    Loading composer repositories with package information
  4.  
    The "https://packagist.org/packages.json" file could not be downloaded: SSL operation failed with code 1. OpenSSL Error messages:
  5.  
    error:14090086:SSL routines:SSL3_GET_SERVER_CERTIFICATE:certificate verify failed
  6.  
    Failed to enable crypto
  7.  
    failed to open stream: operation failedhttps://packagist.org could not be fully loaded, package information was loaded from the local cache and may be out of dateUpdating dependencies (including require-dev)
  8.  
    Nothing to install or update
  9.  
    Generating autoload files

看問題是SSL的驗證問題,網上搜索了很久沒有解決.

下面是來自某被牆的網頁的快照。沒辦法,貼網址也無效。

經過原因查找,在驗證證書的時候出現問題,是本地ssl判別證書太舊,導致報ssl證書錯誤

解決方案一、

下載新的ssl本地判別文件

    wget http://curl.haxx.se/ca/cacert.pem

並更名爲ca-bundle.crt放置到默認目錄。如果該目錄不存在可以創建。

     mv cacert.pem ca-bundle.crt  | mv ca-bundle.crt /etc/pki/tls/certs/

或者curl  –cacert cacert.pem 方式指定調用

然後無意中更改了一下xampp-linux-x64-5.6.8-0-installer.run爲一個老的版本xampp-linux-x64-1.8.3-5-installer.run,竟然可以使用了,你不妨換換版本的。

我在deepin2014.3,64bit操作系統下測試成功解決該error.

解決方案二、[版本太老,不建議用]

借鑑 http://pkg.phpcomposer.com/ 。感謝分享。

修改~/.composer/config.json,添加

 
  1.  
    {
  2.  
        "repositories": [
  3.  
            {"type": "composer", "url": "http://pkg.phpcomposer.com/repo/packagist/"},
  4.  
            {"packagist": false}
  5.  
        ]}

最終是這樣子的。

 
  1.  
    {
  2.  
        "config": {
  3.  
     
  4.  
        },
  5.  
        "repositories": [
  6.  
            {"type": "composer", "url": "http://pkg.phpcomposer.com/repo/packagist/"},
  7.  
            {"packagist": false}
  8.  
        ]}

最終測試可以使用。

解決方案三[完美解決]

參考:https://github.com/composer/composer/issues/3346

First: Check certificate file location which will be in default_cert_file key, you will found it in openssl_get_cert_locations() its php openssl function:

找到驗證文件在哪裏?

這個發現在

/opt/lampp/share/openssl/cert.pem
 
  1.  
    $ php -r "print_r(openssl_get_cert_locations());"
  2.  
    Array
  3.  
    (
  4.  
        [default_cert_file] => /opt/lampp/share/openssl/cert.pem
  5.  
        [default_cert_file_env] => SSL_CERT_FILE
  6.  
        [default_cert_dir] => /opt/lampp/share/openssl/certs
  7.  
        [default_cert_dir_env] => SSL_CERT_DIR
  8.  
        [default_private_dir] => /opt/lampp/share/openssl/private
  9.  
        [default_default_cert_area] => /opt/lampp/share/openssl
  10.  
        [ini_cafile] => 
  11.  
        [ini_capath] => 
  12.  
    )

Second: Download 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:

$ sudo mv cacert.pem /opt/lampp/share/openssl/cert.pem

My php-cli is under XAMPP and default_cert_file maybe point to some place that is different than this.

Fourth:Restart xampp:

sudo /opt/lampp/xampp restart

I hope anything after that should goes fine with you brothers.

發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章