我被困在防火墙后面,所以必须使用HTTPS访问我的GitHub存储库。我在Windows XP上使用cygwin 1.7.7。

我试过把遥控器设置为https://username@github.com/username/ExcelANT.git,但按下输入密码的提示,但输入后没有任何反应。 https://username:<密码>github.com/username/ExcelANT.git和克隆空回购从零开始,但每次它给我同样的错误

错误:SSL证书有问题,请检查CA证书是否正确。细节: SSL例程:SSL3_GET_SERVER_CERTIFICATE:访问https://github.com/username/ExcelANT.git/info/refs时证书验证失败

打开GIT_CURL_VERBOSE=1会给我

* About to connect() to github.com port 443 (#0) * Trying 207.97.227.239... * successfully set certificate verify locations: * CAfile: none CApath: /usr/ssl/certs * SSL certificate problem, verify that the CA cert is OK. Details: error:14090086:SSL routines:SSL3_GET_SERVER_CERTIFICATE:certificate verify failed * Expire cleared * Closing connection #0 * About to connect() to github.com port 443 (#0) * Trying 207.97.227.239... * successfully set certificate verify locations: * CAfile: none CApath: /usr/ssl/certs * SSL certificate problem, verify that the CA cert is OK. Details: error:14090086:SSL routines:SSL3_GET_SERVER_CERTIFICATE:certificate verify failed * Expire cleared * Closing connection #0 error: SSL certificate problem, verify that the CA cert is OK. Details: error:14090086:SSL routines:SSL3_GET_SERVER_CERTIFICATE:certificate verify failed while accessing https://github.com/username/ExcelANT.git/info/refs

fatal: HTTP request failed

这是我的防火墙有问题吗,cygwin还是什么?

我没有在Git配置中设置HTTP代理,但是它是一个ISA服务器,需要NTLM身份验证,不是基本的,所以除非有人知道如何强制Git使用NTLM,否则我就完了。


当前回答

问题是您的系统上没有安装任何证书颁发机构证书。这些证书不能用cygwin的setup.exe安装。

更新:在cygwin安装Net/ca-certificates包(感谢dirkjot)

有两种解决方案:

实际安装根证书。Curl从Mozilla中为您提取证书。

cacert。Pem文件就是你要找的。该文件包含> 250个CA证书(不知道如何信任这个数量的ppl)。你需要下载这个文件,把它分解成单独的证书,把它们放到/usr/ssl/certs(你的CApath)并索引它们。

以下是如何做到这一点。使用cygwin setup.exe安装curl和openssl包 执行:

<!-- language: lang-bash -->

    $ cd /usr/ssl/certs
    $ curl http://curl.haxx.se/ca/cacert.pem |
      awk '{print > "cert" (1+n) ".pem"} /-----END CERTIFICATE-----/ {n++}'
    $ c_rehash

重要提示:为了使用c_rehash,你也必须安装openssl-perl。

Ignore SSL certificate verification. WARNING: Disabling SSL certificate verification has security implications. Without verification of the authenticity of SSL/HTTPS connections, a malicious attacker can impersonate a trusted endpoint (such as GitHub or some other remote Git host), and you'll be vulnerable to a Man-in-the-Middle Attack. Be sure you fully understand the security issues and your threat model before using this as a solution. $ env GIT_SSL_NO_VERIFY=true git clone https://github...

其他回答

如果你在Mac OS X上,你可以通过homebrew安装ca-cert-bundle:

$ brew install curl-ca-bundle
$ git config --system http.sslcainfo /usr/local/share/ca-bundle.crt

该公式通过以下方式将证书包安装到您的共享:

share.install 'ca-bundle.crt'

share方法只是/usr/local/share的别名,而curl-ca-bundle是Mozilla提供的。这是你在很多问题上看到的。希望这能有所帮助,因为它不是很直接的关于如何在Mac OS x上实现这一点,brew install curl也不会让你得到很多,因为它只是keg,不会被链接(运行哪个curl将总是输出/usr/bin/curl,这是你的操作系统自带的默认值)。这篇文章也可能有一些价值。

当然,在安装homebrew之前,您需要禁用SSL,因为它是一个git回购。只做curl在SSL验证期间出错时所说的:

$ echo insecure >> ~/.curlrc

一旦你安装了自制程序和curl-ca-bundle,删除.curlrc并尝试在github上克隆一个repo。确保没有错误,你就可以开始了。

注意:如果你使用。curlrc,请在测试完成后立即将其从系统中删除。此文件可能会导致重大问题,因此仅用于临时目的,请谨慎使用。如果你忘记从你的系统中清除它,酿造医生会抱怨)。

注意:如果你更新了你的git版本,你需要重新运行这个命令,因为你的系统设置将被清除(它们是相对于基于版本的git二进制文件存储的)。

跑步之后:

$ brew update
$ brew upgrade

如果你得到了一个新版本的git,那么只需重新运行:

$ git config --system http.sslcainfo /usr/local/share/ca-bundle.crt

这样你就万事俱备了。

最后,如果你有一个新版本的git,运行:

$ git config -l --system

应该会给出一个类似的错误

无法读取配置文件/usr/local/Cellar/git/1.8.2.2/etc/gitconfig

这是你需要告诉git Mozilla ca-bundle在哪里的提示。

更新:

.curlrc可能是也可能不是解决你的问题的方法。在任何情况下,只要在您的机器上安装Mozilla ca-bundle,不管是否需要手动下载它。这才是最重要的。一旦你得到了ca-bundle,你就可以开始了。只需运行git config命令并将git指向ca-bundle。

更新

我最近不得不补充说:

出口CURL_CA_BUNDLE = / usr /地方/分享/ ca-bundle。crt到我的。zshenv点文件,因为我使用zsh。git配置选项工作在大多数情况下,但当点击github通过SSL (rvm获得稳定的例子),我仍然遇到证书问题。@Maverick在他的评论中指出了这一点,但以防有人忽略了这一点,或者认为除了运行git配置之外,他们不一定需要导出这个环境变量——system....命令。谢谢,希望这能有所帮助。

更新

看来卷曲-ca-bundle最近从自制程序中删除了。这里有一个建议。

你会想把一些文件放到:

$ (openssl - -prefix冲泡)/ etc / / certs

我知道最初的问题列出了Cygwin,但这是CentOS的解决方案:

curl http://curl.haxx.se/ca/cacert.pem -o /etc/pki/tls/certs/ca-bundle.crt

来源:http://eric.lubow.org/2011/security/fixing-centos-root-certificate-authority-issues/

我最近(2014年7月)遇到了类似的问题,在OS X(10.9.4)上发现有一个“DigiCert高保证EV根CA”证书已经过期(尽管我还有另一个未过期的证书)。

开放钥匙串访问 搜寻“数码证书”证书 查看菜单>显示过期证书

我发现了两个名为“DigiCert高保证EV根CA”的证书,一个在2031年11月到期,另一个在2014年7月到期(几天前)。删除过期的证书为我解决了这个问题。

希望这能有所帮助。

如果您想修复证书问题,请跳过这个答案。这个答案涉及ssh通过防火墙的隧道,这是一个更好的解决方案来处理防火墙/代理的事情。

有一个比使用http访问更好的方法,那就是使用ssh服务提供的github端口443的ssh.github.com服务器。

我们使用一种叫做开瓶器的工具。这对于CygWin(通过CygWin主页上的设置)和使用您喜欢的打包工具的Linux都是可用的。对于MacOSX,至少可以从macports和brew中获得。

命令行如下:

$ corkscrew <proxyhost> <proxyport> <targethost> <targetport> <authfile>

proxyhost和proxyport是https代理的坐标。targethost和targetport是要进行隧道连接的主机的位置。authfile是一个文本文件,其中一行包含您的代理服务器用户名/密码,由冒号分隔

e.g:

abc:very_secret

安装使用“正常”的ssh协议进行git通信

通过将其添加到~/。Ssh /config这个技巧可以用于正常的Ssh连接。

Host github.com
  HostName ssh.github.com
  Port 443
  User git
  ProxyCommand corkscrew <proxyhost> <proxyport> %h %p ~/.ssh/proxy_auth

现在您可以通过ssh-ing到gitproxy来测试它的工作

pti@pti-laptop:~$ ssh github.com
PTY allocation request failed on channel 0
Hi ptillemans! You've successfully authenticated, but GitHub does not provide shell access.
       Connection to github.com closed.
pti@pti-laptop:~$

(注意:如果你以前从未登录过github, ssh会要求将服务器密钥添加到已知的hosts文件中。如果你是偏执狂,建议将RSA指纹验证为你上传密钥的github网站上显示的指纹)。

当你需要使用另一个密钥访问存储库时,这种方法有一个轻微的变体,例如,将你的私人帐户与你的专业帐户分开。

# 
# account dedicated for the ACME private github account 
#
Host acme.github.com
  User git
  HostName ssh.github.com
  Port 443
  ProxyCommand corkscrew <proxyhost> <3128> %h %p ~/.ssh/proxy_auth
  IdentityFile ~/.ssh/id_dsa_acme

享受吧!

我们已经在Linux、mac和Windows上使用它很多年了。

如果你愿意,你可以在这篇博客文章中阅读更多有关它的内容

尝试使用命令

git config --global http.sslverify false

该命令将允许来自http的所有不安全的证书,如果在专业环境中使用,请谨慎使用。