当TLSv1失败并显示“忽略的未知记录”时,使git恢复为SSLv3

时间:2013-12-22 21:03:03

标签: git libcurl

无法使用git

git clone https://github.com/foo/bar

失败:

fatal: unable to access 'https://github.com/foo/bar': Unknown SSL  protocol error in connection to github.com:443

如何强制git使用SSLv3?我尝试从源代码编译git,但没有超出设置:--with-openssl(默认)。在remote-curl.c中的第408行之前添加以下行也不起作用:

 curl_easy_setopt(slot->curl, CURLOPT_SSLVERSION, CURL_SSLVERSION_SSLv3);

以下是一些线索:

  • 案例1 :当我的浏览器尝试访问https://github.com/foo/bar时,它首先尝试TLSv1。握手似乎没问题:服务器密钥交换,服务器问候完成(在Wireshark)。但它遵循服务器的“忽略的未知记录”,最后来自服务器的“连接重置”。然后一个新的连接,但SSLv3启动,每件事情都很好(见picture)。

  • 案例2 curl无法使用TLSv1

    curl https://github.com/foo/bar
    

    失败:

    curl: (35) Unknown SSL protocol error in connection to github.com:443
    

    设置--sslv3可解决问题。

  • 案例3 :拿这个

    sudo add-apt-repository  ppa:cassou/emacs
    

    失败:

    pycurl.error: (35, 'gnutls_handshake() failed: A TLS packet with unexpected length was received.')
    

编辑:curl 7.22.0(i686-pc-linux-gnu)libcurl / 7.22.0 OpenSSL / 1.0.1。

修改:调试信息

Cloning into 'bar'...
* Couldn't find host github.com in the .netrc file; using defaults
* About to connect() to github.com port 443 (#0)
*   Trying 192.30.252.130... * Connected to github.com (192.30.252.130) port 443 (#0)
* successfully set certificate verify locations:
*   CAfile: none
    CApath: /etc/ssl/certs
* Unknown SSL protocol error in connection to github.com:443
* Closing connection #0
fatal: unable to access 'https://github.com/foo/bar/': Unknown SSL       protocol error in connection to github.com:443

1 个答案:

答案 0 :(得分:5)

2015年8月更新:Git 2.6 +(2015年第3季度)将允许明确指定SSL版本:

  

http:添加对指定SSL版本的支持

commit 01861cbElia Pinto (devzero2000)(2015年8月14日) 帮助:Eric Sunshine (sunshineco)
(由Junio C Hamano -- gitster --合并于commit ed070a4,2015年8月26日)

http.sslVersion
  

协商SSL连接时使用的SSL版本,如果要强制使用默认值   可用和默认版本取决于libcurl是针对NSS还是OpenSSL构建的,以及正在使用的加密库的特定配置。在内部设置'CURLOPT_SSL_VERSION'选项;有关此选项的格式以及支持的ssl版本的更多详细信息,请参阅libcurl文档   实际上,此选项的可能值为:

     
      
  • SSLV2
  •   
  • SSLV3
  •   
  • 使用TLSv1
  •   
  • tlsv1.0
  •   
  • tlsv1.1
  •   
  • TLSv1.2工作
  •   
     

可以被“GIT_SSL_VERSION”环境变量覆盖   要强制git使用libcurl的默认ssl版本并忽略任何显式http.sslversion选项,请将'GIT_SSL_VERSION'设置为空字符串。


原始回答Dec:2013

当我的PROXY环境变量未正确设置时,我通常会看到错误消息:

export HTTP_PROXY=http://user:password@proxy.mycompany.com:port
export HTTPS_PROXY=http://user:password@proxy.mycompany.com:port
export NO_PROXY=.mycompany.com

您还可以setup a ~/.netrc file获取GitHub凭据。

确保 git config http.sslcainfo 引用您的 /path/to/git/bin/curl-ca-bundle.crt ,以便curl能够验证与GitHub服务器关联的证书


一种解决方法,如果https确实不起作用,则使用ssh url

git clone ssh://user@server:project.git

(如果您先生成了私钥和公钥,并将该公钥注册到您的GitHub帐户)