如何在不重建包的情况下让git告诉curl使用openssl而不是gnutls?

lyt*_*yte 5 git ubuntu curl openssl gnutls

我们有一个GnuTLS不喜欢的内部服务器,例如:

gnutls-cli --x509cafile /etc/ssl/certs/ca-certificates.crt foo.example.com
Processed 173 CA certificate(s).
Resolving 'foo.example.com'...
Connecting to '1.2.3.4:443'...
*** Verifying server certificate failed...
*** Fatal error: Error in the certificate.
*** Handshake has failed
GnuTLS error: Error in the certificate.
Run Code Online (Sandbox Code Playgroud)

GnuTLS以外的所有内容都可以正常使用,但是git似乎在Ubuntu 14.04.2 LTS上使用GnuTLS开箱即用,所以git失败了:

GIT_CURL_VERBOSE=1 git clone https://foo.example.com/some-repo.git
Cloning into 'some-repo'...
* Couldn't find host foo.example.com in the .netrc file; using defaults
* Hostname was NOT found in DNS cache
*   Trying 1.2.3.4...
* Connected to foo.example.com (1.2.3.4) port 443 (#0)
* found 173 certificates in /etc/ssl/certs/ca-certificates.crt
* server certificate verification failed. CAfile: /etc/ssl/certs/ca-certificates.crt CRLfile: none
* Closing connection 0
fatal: unable to access 'https://foo.example.com/some-repo.git/': server certificate verification failed. CAfile: /etc/ssl/certs/ca-certificates.crt CRLfile: none
Run Code Online (Sandbox Code Playgroud)

我们正在努力修复与GnuTLS的不兼容性,但同时有一种方法可以强制git告诉curl在运行时使用另一个SSL引擎(即不从源代码重建git)?

Dan*_*erg 10

git构建为使用libcurl,libcurl构建为使用单个固定的TLS库,无法在运行时更改.

但是,您可以强制git在运行时使用不同的libcurl构建,并且libcurl可能正在使用OpenSSL.最简单的方法是将OpenSSL - 使用libcurl放在一个与你所拥有的"标准"目录不同的目录中,然后你做其中一个:

  1. 确保/etc/ld.so.conf在旧的libcurl托管目录之前列出新的dir - 虽然它会使用libcurl为所有程序更改此设置,但您可能不希望这样(基于您的询问方式)

  2. 将"LD_LIBRARY_PATH = [您的特殊libcurl所在的目录] git"放入名为"git2"的脚本或别名中,并使用它而不是普通的git.