【问题标题】:How to add an enterprise certificate authority (CA) to git on cygwin (and some linux distros)如何在 cygwin(和一些 Linux 发行版)上将企业证书颁发机构 (CA) 添加到 git
【发布时间】:2014-10-27 14:58:33
【问题描述】:

在 Cygwin 上使用 git 获取时,您会得到:

Fetching origin
fatal: unable to access 'https://.../...git': SSL certificate problem: self signed certificate in certificate chain
error: Could not fetch origin

证书已添加到 /etc/ssl/certs/ca-bundle.crtother bundle files,但在下一次 Cygwin 更新时问题再次出现。

【问题讨论】:

标签: git ssl cygwin certificate ca


【解决方案1】:

git-remote-https 将读取以下文件以获取 ca 证书:

/etc/ssl/certs/ca-bundle.crt
/etc/pki/ca-trust/extracted/openssl/ca-bundle.trust.crt

如果您编辑这些文件,它们将在每次运行 Cygwin 安装程序并且 ca-certificates 包有更新时被覆盖。

正确/正确的解决方案是将证书添加到pickup目录并运行pickup脚本,update-ca-trust:

curl -sL http://ca.pdinc.us  > /etc/pki/ca-trust/source/anchors/ca.pdinc.us.pem \
&& update-ca-trust

ca-certificates 软件包的安装后脚本将在每次升级时自动重新运行 update-ca-trust 脚本。欲了解更多信息:

man update-ca-trust

【讨论】:

  • curl -sL 命令应该做什么?它是 http URL,因此显然没有从上下文中获得证书链。
  • 在当前版本中,git-remote-https/mingw64/ssl/certs/ca-bundle.crt 读取证书,因为它是在/c/ProgramData/Git/config 中配置的。 /mingw64/bin/update-ca-trust/usr/bin/update-ca-trust 都不会更新该文件,因此该脚本没有用。我还没找到。
  • @JanHudec 截至今天的更新,自 2014 年以来似乎并非如此。你在用什么 git --version (git version 2.8.3) 和 uname -a (CYGWIN_NT-6.1-WOW black7 2.6.1(0.305/5/3) 2016-12-16 11:50 i686 Cygwin)?跨度>
  • git version 2.11.0.windows.3, MINGW64_NT-6.1 ntb1005941 2.6.1(0.306/5/3) 2017-01-14 09:41 x86_64 Msys。行;我没有意识到您实际上正在使用 git 的 cygwin 版本——我总是将原生版本与 cygwin 一起使用,因为我需要原生应用程序来使用它。请注意,由于 msys2 是 cygwin 的一个分支,因此两者都有脚本。其实msys2有3份,msys一份,mingw32一份,mingw64一份。并且 git install 无论如何都不会使用它。
  • 如果你运行 GIT_CURL_VERBOSE=true git clone https://google.com 并寻找 CAfileCApath,那么 git 不是 Cygwin git
【解决方案2】:

更简单的说明:

  1. 只需复制带有您企业可信证书的文件(例如,.crt 文件)并将它们复制到目录/etc/pki/ca-trust/source/anchors/ 中。

  2. 运行update-ca-trust extract。这将生成各种文件以使一切正常运行。

您可以在目录中添加或删除文件并重新运行update-ca-trust extract

注意:如果您的组织是少数使用扩展 BEGIN TRUSTED 文件格式的专用证书(可能包含不信任/黑名单信任标志,或用于 TLS 以外的用途的信任标志)的组织之一,则略有变化在步骤 1 中。基本上,将证书复制到目录 /etc/pki/ca-trust/source/ 中。将它们复制到“常用”位置并在“常用”目录不起作用时稍后移动它们没有任何害处。

更多详情,请运行man update-ca-trust

【讨论】:

  • 我的 linux mint 上没有 /etc/pki/ca-trust/source/anchors/ 这个路径
  • git 仍然拒绝信任我添加的 .pem 证书(RHEL 8)
猜你喜欢
  • 2015-05-30
  • 2014-12-26
  • 2012-05-13
  • 2016-08-30
  • 2011-12-18
  • 1970-01-01
  • 2010-11-02
  • 1970-01-01
相关资源
最近更新 更多