tl;dr
由于神秘的“SSL 协议(protocol)”错误,Windows 上的 Git 停止连接到 github。住手!
问题
我正在 Windows 上开发,使用私有(private) GitHub 存储库进行源代码控制。当我第一次启动我的系统时,我能够毫无问题地访问远程存储库 - pull
、push
、fetch
等。一切正常就好了。
经过一段时间 (*),此过程停止,我收到以下错误:
fatal: unable to access 'https://github.com/our-team/private-repo.git/': Unknown SSL protocol error in connection to github.com:443
(*) 时间的长短似乎是可变的——我见过少则一两个小时,多则一整天。一般系统休眠回来后,好像是问题,不知道是时间延迟还是系统休眠导致的。
通过 cURL 检查,我得到
λ curl -v "https://github.com/our-team/private-repo.git/"
* Trying 192.30.252.130...
* Connected to github.com (192.30.252.130) port 443 (#0)
* successfully set certificate verify locations:
* CAfile: C:\Program Files (x86)\Git\bin\curl-ca-bundle.crt
CApath: none
* TLSv1.0, TLS handshake, Client hello (1):
* Unknown SSL protocol error in connection to github.com:443
* Closing connection 0
curl: (35) Unknown SSL protocol error in connection to github.com:443
使用 set GIT_CURL_VERBOSE=1
和 git pull
显示类似的信息。有时会成功(见下文),但大多数时候会失败。
进一步说明
它有一点零星的性质 - 有时我可以收到成功的请求,但一旦它开始爆炸,通常 10 个请求中有 9 个或更多被破坏。
成功的 cURL 请求如下所示:
λ curl -v "https://github.com/our-team/private-repo.git/"
* Trying 192.30.252.130...
* Connected to github.com (192.30.252.130) port 443 (#0)
* successfully set certificate verify locations:
* CAfile: C:\Program Files (x86)\Git\bin\curl-ca-bundle.crt
CApath: none
* TLSv1.0, TLS handshake, Client hello (1):
* TLSv1.0, TLS handshake, Server hello (2):
* TLSv1.0, TLS handshake, CERT (11):
* TLSv1.0, TLS handshake, Server finished (14):
* TLSv1.0, TLS handshake, Client key exchange (16):
* TLSv1.0, TLS change cipher, Client hello (1):
* TLSv1.0, TLS handshake, Finished (20):
* TLSv1.0, TLS change cipher, Client hello (1):
* TLSv1.0, TLS handshake, Finished (20):
* SSL connection using TLSv1.0 / AES128-SHA
* Server certificate:
* subject: businessCategory=Private Organization; 1.3.6.1.4.1.311.60.2.1.3=US; 1.3.6.1.4.1.311.60.2.1.2=Delaware; serialNumber=5157550; street=548 4th Street; postalCode=94107; C=US; ST=California; L=San Francisco; O=GitHub, Inc.; CN=github.com
* start date: 2014-04-08 00:00:00 GMT
* expire date: 2016-04-12 12:00:00 GMT
* subjectAltName: github.com matched
* issuer: C=US; O=DigiCert Inc; OU=www.digicert.com; CN=DigiCert SHA2 Extended Validation Server CA
* SSL certificate verify ok.
> GET /our-team/private-repo.git/ HTTP/1.1
> User-Agent: curl/7.41.0
> Host: github.com
> Accept: */*
>
< HTTP/1.1 301 Moved Permanently
< Server: GitHub.com
< Date: Mon, 11 May 2015 15:19:43 GMT
< Content-Type: text/html
< Content-Length: 178
< Location: https://github.com/our-team/private-repo/
< Vary: Accept-Encoding
< X-Served-By: 76f8aa18dab86a06db6e70a0421dc28c
<
<html>
<head><title>301 Moved Permanently</title></head>
<body bgcolor="white">
<center><h1>301 Moved Permanently</h1></center>
<hr><center>nginx</center>
</body>
</html>
* Connection #0 to host github.com left intact
问题
我在谷歌上搜索了很多试图找到这个(在几个星期的过程中,所以我没有链接),但大多数建议似乎指向证书错误或 OpenSSL 版本不匹配/错误(这将像这样 AFAIK 是零星的)。
什么可能导致此失败,我该如何解决?
相关软件:
λ git --version
git version 1.9.5.msysgit.1
λ curl --version
curl 7.41.0 (i386-pc-win32) libcurl/7.41.0 OpenSSL/0.9.8zf zlib/1.2.8
Protocols: dict file ftp ftps gopher http https imap imaps ldap ldaps pop3 pop3s rtsp smtp smtps telnet tftp
Features: AsynchDNS IPv6 Largefile SSPI Kerberos SPNEGO NTLM SSL libz
最佳答案
奇怪的是,事实证明问题出在笔记本电脑因供电不足而被节流。我使用的扩展坞插入了一个低电流电源 (3.3 A),虽然它与笔记本电脑兼容,但立即将其踢入了严重节流模式。
显然,这使一切都变慢了,以至于 SSL 握手无法足够快地完成。
我们最终在阅读了讨论缓慢问题的戴尔支持论坛帖子 (http://en.community.dell.com/support-forums/laptop/f/3518/t/19363340) 后找到了它。解决方案是更换电源。
我也遇到过这种慢,但我不认为它是相关的。我们为扩展坞更换了高功率电源,一切都恢复正常,上述 SSL 错误消失了。
关于windows - 由于 "SSL protocol"错误,Windows 上的 Git 无法使用远程,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/30172250/