composer.phar在使用nss和api.github.com时出现问题

4
我试图在安装了RHEL6的服务器上使用composer.phar。
安装细节如下: curl/7.19.7 (x86_64-redhat-linux-gnu) libcurl/7.19.7 NSS/3.14.3.0 zlib/1.2.3 libidn/1.18 libssh2/1.4.2 PHP 5.4.16 Zend Engine v2.4.0,版权所有(c) 1998-2013 Zend Technologies
我的composer.json内容如下:
{
    "name" : "zendframework/skeleton-application",
    "description" : "Skeleton Application for ZF2",
    "keywords" : [
        "framework",
        "zf2"
    ],
    "homepage" : "https://something.com/",
    "require" : {
        "php" : ">=5.3.3",
        "zendframework/zendframework" : "2.*"
    }
}

运行php composer.phar update 会导致以下结果:
Loading composer repositories with package information
Updating dependencies (including require-dev)
  - Installing zendframework/zendframework (2.2.5)
    Downloading: 100%
    Downloading: 100%
    Downloading: 100%



  [Composer\Downloader\TransportException]
  The "https://api.github.com/repos/zendframework/zf2/zipball/4a7cf6a4cf791244e14aa0ca49d1f06916b63202" file could not be downloaded: SSL: Connection reset by peer
  Failed to enable crypto
  failed to open stream: operation failed

下一步是尝试使用curl:

$ curl -vvv "https://api.github.com/repos/zendframework/zf2/zipball/4a7cf6a4cf791244e14aa0ca49d1f06916b63202"
* About to connect() to api.github.com port 443 (#0)
*   Trying 192.30.252.139... connected
* Connected to api.github.com (192.30.252.139) port 443 (#0)
* Initializing NSS with certpath: sql:/etc/pki/nssdb
*   CAfile: /etc/pki/tls/certs/ca-bundle.crt
  CApath: none
* NSS error -5961
* Closing connection #0
* SSL connect error
curl: (35) SSL connect error

强制使用SSLV3是有效的:

curl -3 -vvv "https://api.github.com/repos/zendframework/zf2/zipball/4a7cf6a4cf791244e14aa0ca49d1f06916b63202"
* About to connect() to api.github.com port 443 (#0)
*   Trying 192.30.252.138... connected
* Connected to api.github.com (192.30.252.138) port 443 (#0)
* Initializing NSS with certpath: sql:/etc/pki/nssdb
*   CAfile: /etc/pki/tls/certs/ca-bundle.crt
  CApath: none
* SSL connection using SSL_RSA_WITH_RC4_128_SHA
* Server certificate:
*       subject: CN=*.github.com,O="GitHub, Inc.",L=San Francisco,ST=California,C=US
*       start date: Apr 30 00:00:00 2012 GMT
*       expire date: Jul 09 12:00:00 2014 GMT
*       common name: *.github.com
*       issuer: CN=DigiCert High Assurance CA-3,OU=www.digicert.com,O=DigiCert Inc,C=US
> GET /repos/zendframework/zf2/zipball/4a7cf6a4cf791244e14aa0ca49d1f06916b63202 HTTP/1.1
> User-Agent: curl/7.19.7 (x86_64-redhat-linux-gnu) libcurl/7.19.7 NSS/3.14.3.0 zlib/1.2.3 libidn/1.18 libssh2/1.4.2
> Host: api.github.com

有人遇到过composer.phar的这个问题并且解决了吗(能分享一下他/她的解决方案吗:-))?我知道composer使用PHP的file_get_contents()。


我知道Composer使用PHP的file_get_contents()函数,而该函数本身使用curl。但我强烈怀疑这是不正确的;file_get_contents()是PHP核心的一部分,根本不依赖于libcurl。 - Levi Morrison
如果是这种情况,那么文档中的示例有点误导(可能只是错位了):http://php.net/manual/en/context.curl.php我会从问题中删除这个假设,因为我不想分散注意力。这也可能解释为什么操纵curl上下文选项似乎没有任何影响。 - tedb
1个回答

2

虽然不是最佳解决方案,但为了节省时间,我绕过了这个问题。我从错误输出中获取了URL:

https://api.github.com/repos/zendframework/zf2/zipball/4a7cf6a4cf791244e14aa0ca49d1f06916b63202

我把它插入到我的Windows工作站中的浏览器中。在使用composer的用户的主目录下,是一个名为.composer的目录,我将下载的zip文件放到了这个目录中。

/home/composeruser/.composer/cache/files/zendframework/zendframework

然后我需要将zip文件重命名为URL所要求的名称(添加zip扩展名):

/home/composeruser/.composer/cache/files/zendframework/zendframework/4a7cf6a4cf791244e14aa0ca49d1f06916b63202.zip

下次运行composer时,它将使用缓存的文件并继续执行。如果有人找到一种避免在带有NSS的RHEL6箱上预缓存文件的方法,请告诉我。

网页内容由stack overflow 提供, 点击上面的
可以查看英文原文,
原文链接