apache - SSL 适用于浏览器、wget 和 curl,但不适用于 git

标签 apache git ssl redmine

我有一个用于托管 redmine 和几个 git 存储库的网站

这对 http 非常有效,但我不能用 https 克隆,即

git clone http://mysite.com/git/test.git

工作正常,但是

git clone https://mysite.com/git/test.git

失败

奇怪的是 https 似乎适用于我测试过的所有其他内容。如果我打开

https://mysite.com/git/test.git

在浏览器中(在 chrome 和 firefox 中测试),我没有收到任何错误或警告。我也可以

curl https://mysite.com/git/test.git
wget https://mysite.com/git/test.git

两者都没有投诉或警告。

这是 git 的详细输出:

$ GIT_CURL_VERBOSE=1 git clone https://user@mysite.com/test/test.git
Cloning into test...
Password:
* Couldn't find host mysite.com in the .netrc file; using defaults
* About to connect() to mysite.com port 443 (#0)
*   Trying 127.0.0.1... * Connected to mysite.com (127.0.0.1) port 443 (#0)
* found 157 certificates in /etc/ssl/certs/ca-certificates.crt
* server certificate verification failed. CAfile: /etc/ssl/certs/ca-certificates.crt CRLfile: none
* Closing connection #0
* Couldn't find host mysite.com in the .netrc file; using defaults
* About to connect() to mysite.com port 443 (#0)
*   Trying 127.0.0.1... * Connected to mysite.com (127.0.0.1) port 443 (#0)
* found 157 certificates in /etc/ssl/certs/ca-certificates.crt
* server certificate verification failed. CAfile: /etc/ssl/certs/ca-certificates.crt CRLfile: none
* Closing connection #0
error: server certificate verification failed. CAfile: /etc/ssl/certs/ca-certificates.crt CRLfile: none while accessing https://user\
@mysite.com/test/test.git/info/refs

fatal: HTTP request failed

这是 curl 的详细输出,个人信息已更改:

* About to connect() to mysite.com port 443 (#0)
*   Trying 127.0.0.1... connected
* Connected to mysite.com (127.0.0.1) port 443 (#0)
* successfully set certificate verify locations:
*   CAfile: none
  CApath: /etc/ssl/certs
* SSLv3, TLS handshake, Client hello (1):
* SSLv3, TLS handshake, Server hello (2):
* SSLv3, TLS handshake, CERT (11):
* SSLv3, TLS handshake, Server key exchange (12):
* SSLv3, TLS handshake, Server finished (14):
* SSLv3, TLS handshake, Client key exchange (16):
* SSLv3, TLS change cipher, Client hello (1):
* SSLv3, TLS handshake, Finished (20):
* SSLv3, TLS change cipher, Client hello (1):
* SSLv3, TLS handshake, Finished (20):
* SSL connection using DHE-RSA-AES256-SHA
* Server certificate:
*        subject: C=US; <... cut my certs info ...>
*        start date: 2011-10-18 00:00:00 GMT
*        expire date: 2013-10-17 23:59:59 GMT
*        subjectAltName: mysite.com matched
*        issuer: C=GB; ST=Greater Manchester; L=Salford; O=COMODO CA Limited; CN=COMODO High-Assurance Secure Server CA
*        SSL certificate verify ok.
> GET / HTTP/1.1
> User-Agent: curl/7.21.6 (x86_64-pc-linux-gnu) libcurl/7.21.6 OpenSSL/1.0.0e zlib/1.2.3.4 libidn/1.22 librtmp/2.3
> Host: mysite.com
> Accept: */*
>
< HTTP/1.1 200 OK
< Date: Tue, 18 Oct 2011 21:39:54 GMT
< Server: Apache/2.2.14 (Ubuntu)
< Last-Modified: Fri, 14 Oct 2011 03:20:01 GMT
< ETag: "8209c-87-4af39bb89ccac"
< Accept-Ranges: bytes
< Content-Length: 135
< Vary: Accept-Encoding
< Content-Type: text/html
< X-Pad: avoid browser bug
<
<p>Welcome to the mysite.com<p/>
* Connection #0 to host mysite.com left intact
* Closing connection #0
* SSLv3, TLS alert, Client hello (1):

我能看到的唯一区别是 git 似乎使用了一个明确的 CAfile 而 curl 使用了整个目录?我是 ssl 的新手(至少在管理员方面是这样),所以我不确定这意味着什么或者我如何配置 git 使其以与 curl 相同的方式工作。

我在 Ubuntu 10.04 上使用 git 1.7.5.4 和 apache 2.2.14。我已经尝试从 3 个不同的 Linux 主机(包括服务器本身上的另一个帐户)克隆,但没有任何效果。

我还使用 openssl 工具在服务器上验证我的证书:

$openssl verify -purpose sslserver -CAfile chain.crt signed.pem 
signed.pem: OK

这可能与错误https://bugs.maemo.org/show_bug.cgi?id=4953有关但它似乎有所不同,因为我在任何其他程序中都没有收到任何警告或错误。

可能值得一提的是,我正在使用 gitolite 和 redmine_git_hosting使用智能 http 通过 https 进行身份验证。我不认为这有任何问题,因为即使我只是在/var/www 中粘贴一个其他工作的裸仓库并直接访问它,问题仍然存在。此外,git over ssh(有和没有 gitolite)都可以工作。

如果您有任何想法可能出了什么问题,或者如果您想了解更多信息,请告诉我。我真的更愿意让 ssl 正常工作,而不是强制每个人在 git 中禁用证书检查,尽管这是当前的解决方法。

感谢阅读这篇长文!

最佳答案

原来这是一个 gnuTLS 问题。 gnuTLS 是顺序敏感的,而 openssl 不是。我重新订购了我的中间证书文件中的证书,问题就消失了

关于apache - SSL 适用于浏览器、wget 和 curl,但不适用于 git,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/7814423/

相关文章:

c# - FTP over SSL 问题

java - 在 JDK 1.7 中连接到 https 站点时出现问题

php - 找不到 Prestashop 1.7 模块目录数据

php - Homestead + Symfony 2.7 安装

php - 更改PHP上传文件的权限

git - 不要重复自己的 git 修订范围语法?

git - 从 git 中删除大量提交

java - Java 中的 Docx 到 Pdf 转换器

eclipse - 如何使用 EGIT 将现有的 Eclipse 项目推送到 Bitbucket?

.htaccess - 如何在重定向到 https 时允许通过 .htaccess 进行 ec2 健康检查