composer完全禁用https

时间:2014-01-04 13:15:43

标签: ssl https composer-php

我的网络无法正常使用https,所以正在执行

composer.phar install

引发

  [Composer\Downloader\TransportException]                                                         
  The "https://packagist.org/packages.json" file could not be downloaded: Failed to enable crypto  
  failed to open stream: operation failed  

我用过

{
    "packagist": false
},
{
    "type": "composer",
    "url": "http://packagist.org",
    "options": {
        "ssl": {
            "verify_peer": "false"
        }
    }
}

作为一个http falback,但它又在其他方面崩溃了:

Installing dependencies
  - Installing symfony/translation (v2.4.0)
    Downloading: 100%         
    Downloading: 100%         
    Downloading: 100%         



  [Composer\Downloader\TransportException]                                                                                                          
  The "https://api.github.com/repos/symfony/Translation/zipball/0919e0fc709217f8c9e5049f2603419fdd4a34ff" file could not be downloaded: Failed to   
  enable crypto                                                                                                                                     
  failed to open stream: operation failed               

我的问题只是TLSv1,以前的SSL版本应该可以使用,因为浏览器可以正常工作。

我应该怎么做,这个问题也存在于依赖于https的其他cmd工具中,如npm,bower,git,curl,......

6 个答案:

答案 0 :(得分:15)

您可以使用composer.json关闭TLS(对于您的特定项目):

{
    "require": {
        "laravel/framework": "5.2.43"
    },
    "config": {
        "preferred-install": "dist",
        "disable-tls": true,
        "secure-http": false
    }    
}

NB :不要在配置部分中使用“disable-tls”:true

答案 1 :(得分:12)

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

答案 2 :(得分:4)

您无法使用Composer禁用SSL。即使它像您的设置一样工作,也无法控制您使用的任何包的源URL。其中一些没有提供任何SSL,所以你必须使用SSL。

我认为让SSL工作是最好的主意。您是否尝试composer diag并查看问题所在?

答案 3 :(得分:4)

它很好。 它会工作。你只是不匹配:

"options": {
    "ssl": {
        "verify_peer": false
    }
}

答案 4 :(得分:3)

为了禁用https totaly(不推荐) 你需要在你的composer.json文件配置键中添加" secure-http":false,如下所示:

"name": "laravel/laravel",
"description": "The Laravel Framework.",
"keywords": ["framework", "laravel"],
"license": "MIT",
"require": {
    "laravel/framework": "5.3.*",
},
.
.
.
"config": {
    "preferred-install": "dist",
    "bin-dir": "vendor/bin/",
    "secure-http": false
},
"minimum-stability": "dev"

答案 5 :(得分:0)

问题很简单,您将"false"用引号引起来,即true when converted to bool

使用"verify_peer": false代替"verify_peer": "false"

{
  "repositories": [
    {
      "type": "composer",
      "url": "http://packagist.org",
      "options": {
        "ssl": {
          "verify_peer": false
        }
      }
    }
  ]
}