composer不知什么原因,遇到https,就会报SSL: Handshake timed out,Google也没结果

[Composer\Downloader\TransportException] The "https://packagist.org/packages.json" file could not be downloaded: SSL: Handshake timed out

执行: composer diagnose检查显示

[root@iZm5e5k2yby7w6yyixdif3Z .composer]# composer diagnose
Do not run Composer as root/super user! See https://getcomposer.org/root for details
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://packagist.org/packages.json" file could not be downloaded: SSL: Handshake timed out
Failed to enable crypto
failed to open stream: operation failed
Checking github.com rate limit: FAIL
[Composer\Downloader\TransportException] The "https://api.github.com/rate_limit" file could not be downloaded: SSL: Handshake timed out
Failed to enable crypto
failed to open stream: operation failed
Checking disk free space: OK
Checking pubkeys: FAIL
Missing pubkey for tags verification
  ssing 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: Handshake timed out  
  Failed to enable crypto                                                                        
  failed to open stream: operation failed                                                        
                                                                                                 

diagnose

执行

 php -r "copy('https://install.phpcomposer.com/installer', 'composer-setup.php');"

显示

PHP Warning:  copy(): SSL: Handshake timed out in Command line code on line 1
PHP Warning:  copy(): Failed to enable crypto in Command line code on line 1
PHP Warning:  copy(https://install.phpcomposer.com/installer): failed to open stream: operation failed in Command line code on line 1
阅读 25.9k
7 个回答

打开php.ini, 将default_socket_timeout值调大。如:default_socket_timeout=360(默认为-1或60)

我觉得这种奇怪的情况,要么

  • 翻墙

  • 使用国内 composer 镜像

试试用浏览器请求 https://install.phpcomposer.com/installer, 下载文件后传至服务器 重命名为composer-setup.php

几个解决方案

  1. 检查一下代理,如果有设置,先清空掉

      $ echo $https_proxy
      $ unset https_proxy
  2. wget https://curl.haxx.se/ca/cacer... 到 /path/to/certs

        # 并设置你的php.ini (php --ini)
        curl.cainfo    = /path/to/certs/cacert.pem
        openssl.cafile = /path/to/certs/cacert.pem
        openssl.capath = /path/to/certs
  3. ipv6的问题(官方给的解决方案)

        $ sudo sh -c "echo 'precedence ::ffff:0:0/96 100' >> /etc/gai.conf"
  4. composer diagnose 检查的时候,https FAILED的问题

        $ composer config -g secure-http false

换成国内镜像试试

就是网络差。或者不通。。。

撰写回答
你尚未登录,登录后可以
  • 和开发者交流问题的细节
  • 关注并接收问题和回答的更新提醒
  • 参与内容的编辑和改进,让解决方法与时俱进
推荐问题