git - 如何让 git 告诉 curl 使用 openssl 而不是 gnutls 而无需重建包?

标签 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.

除了 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

我们正在努力解决与 GnuTLS 的不兼容问题,但与此同时,有没有办法强制 git 告诉 curl 在运行时使用另一个 SSL 引擎(即不从源代码重建 git)?

最佳答案

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

然而,您可以强制 git 在运行时使用不同的 libcurl 构建,而该 libcurl 可能正在使用 OpenSSL。最简单的方法是将使用 OpenSSL 的 libcurl 放在与您拥有的“标准”目录不同的目录中,然后执行以下操作之一:

  1. 确保 /etc/ld.so.conf 在旧的 libcurl 托管目录之前列出新目录 - 虽然它会更改所有使用 libcurl 的程序的设置,你可能不想要那个(根据你的询问方式)

  2. 将“LD_LIBRARY_PATH=[你的特殊 libcurl 所在的目录] git”放入名为“git2”的脚本或别名中,并使用它代替普通的 git。

关于git - 如何让 git 告诉 curl 使用 openssl 而不是 gnutls 而无需重建包?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/29245292/

相关文章:

php - 获取 HTTP 请求然后处理 HTML 响应的最佳方法

git - 如何列出被 'skip-worktree' 忽略的文件

c# - GIT - 不能忽略 .suo 文件

django - httpd.conf 在哪里?

matlab - XLSREAD 无法在 MATLAB R2012 中读取文件

shell - 如何在ubuntu中创建sh文件的安装程序

java - pom.xml 中的 Maven 部署参数

git - 如何空运行 git push 来检查一个人是否具有对远程的写入权限?

php - 安装 Composer 时出错 - curl : (23) Failed writing body (0 ! = 16133)

c++ - 如何使用http请求只获取字符串名称