【问题标题】:How can I make git tell curl to use openssl instead of gnutls without rebuilding the package?如何让 git 告诉 curl 在不重建包的情况下使用 openssl 而不是 gnutls?
【发布时间】:2015-03-25 00:12:19
【问题描述】:

我们有一个 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)?

【问题讨论】:

  • Fatal error: Error in the certificate。在解析证书数据时,GnuTLS 比 OpenSSL 等许多库更严格。也许要问的问题是,证书有什么问题。我猜名称 foo.example.com1.2.3.4 未列为 SubjectAltName。 如果您提供了真实信息,那么我们或许能够为您提供帮助。如果您询问证书有什么问题,请在另一个有主题的网站上进行,例如超级用户。
  • AWS CodeCommit 给出了这个错误,fwiw。
  • @jww 就我的问题而言,我已经准确地询问了我关心的问题并得到了我需要的答案。有问题的证书问题并不像我说的那样重要,这是被独立看待的(我自己无权修复它,也无法对那些修复它的人产生太大影响)。

标签: git ubuntu curl openssl gnutls


【解决方案1】:

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。

【讨论】:

    猜你喜欢
    • 2014-12-11
    • 2021-05-05
    • 2017-03-18
    • 2013-05-17
    • 2023-03-29
    • 2010-10-13
    • 2011-07-15
    • 2019-07-28
    • 1970-01-01
    相关资源
    最近更新 更多