简体   繁体   English

如何将 Git 配置为信任来自 Windows 证书存储的证书?

[英]How do I configure Git to trust certificates from the Windows Certificate Store?

Currently I have the following entry in my .gitconfig in my user directory.目前,我的用户目录中的.gitconfig中有以下条目。

...
[http]
    sslCAInfo=C:\\Users\\julian.lettner\\.ssh\\git-test.pem
...

This sets the certificate to use when interacting with the git server (required by my company's git server).这设置了与 git 服务器交互时使用的证书(我公司的 git 服务器需要)。

But now I cannot clone other repositories (for example a public repository on GitHub), because the client always uses the configured certificate which gets rejected by other servers.但是现在我无法克隆其他存储库(例如 GitHub 上的公共存储库),因为客户端始终使用被其他服务器拒绝的已配置证书。

How can I circumvent this certification issue?我怎样才能避免这个认证问题? Can I configure Git to use the Windows Certificate Store to authenticate?我可以将 Git 配置为使用 Windows 证书库进行身份验证吗?

Beginning with Git for Windows 2.14, you can now configure Git to use SChannel, the built-in Windows networking layer. 从Git for Windows 2.14开始,您现在可以将Git配置为使用内置Windows网络层SChannel。 This means that it will use the Windows certificate storage mechanism and you do not need to explicitly configure the curl CA storage mechanism. 这意味着它将使用Windows证书存储机制,你并不需要显式配置卷曲CA存储机制。

From the Git for Windows 2.14 release notes : 从Git for Windows 2.14 发行说明

It is now possible to switch between Secure Channel and OpenSSL for Git's HTTPS transport by setting the http.sslBackend config variable to "openssl" or "schannel" ; 现在可以通过将http.sslBackend配置变量设置为"openssl""schannel"来在安全通道和OpenSSL之间切换Git的HTTPS传输; This is now also the method used by the installer (rather than copying libcurl-4.dll files around). 现在这也是安装程序使用的方法(而不是复制libcurl-4.dll文件)。

You can choose the new SChannel mechanism during the installation of Git for Windows 2.14. 您可以在安装Git for Windows 2.14期间选择新的SChannel机制。 You can also update an existing installation to use SChannel by running: 您还可以通过运行以下内容来更新现有安装以使用SChannel:

git config --global http.sslBackend schannel

Once you have configured this, Git will use the Windows certificate store and should not require (and, in fact, should ignore) the http.sslCAInfo configuration setting. 配置完成后,Git将使用Windows证书存储,并且不应要求(实际上应该忽略) http.sslCAInfo配置设置。

Use: 采用:

git config  --local ...

To specify per-repository settings. 指定每个存储库设置。 Local settings are stored in the .git directory. 本地设置存储在.git目录中。

An overview of the three locations where git can store settings: git可以存储设置的三个位置的概述:

  • --local : Repository specific, <repo_dir>/.git/config --local :特定--local存储库, <repo_dir>/.git/config
  • --global : User-specific, ~/.gitconfig --global :特定于用户, ~/.gitconfig
  • --system : System default, /etc/gitconfig --system :系统默认, /etc/gitconfig

More specific ones override more general settings, ie local overrides both global and system. 更具体的覆盖更多一般设置,即全局和系统的本地覆盖。

I had the same problem and the solution was to clone git repository with url starting with 'http' instead of 'https'我遇到了同样的问题,解决方案是克隆 git 存储库,url 以“http”而不是“https”开头

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 Java 客户端不从 Windows 信任存储中选择根/中间证书 - Java client not picking root/intermediate certificates from Windows Trust Store 如何使用CryptoAPI在Windows7上获取证书信任列表 - How do i get Certificate Trust List on windows7 using CryptoAPI 从证书和私钥导入证书到windows - Import certificates into windows from certificate and private key 在C#中将证书安装到Windows本地用户证书存储中 - Install certificates in to the Windows Local user certificate store in C# 如何在 python 中使用 Windows 证书存储中的客户端证书? - How to use a client certificate from the Windows certificate store in python? 如何为Windows配置OpenGL Makefile?(来自Linux) - How do I configure an OpenGL makefile for Windows?(from Linux) 如何使用C ++在Windows用户存储中添加客户端证书和私钥? - How do I add a Client Certificate and Private Key to the Users Store in Windows with C++? 如何在Nodejs中使用Windows应用商店的服务器证书 - How to use a Server Certificate from the Windows Store in Nodejs 如何使用python使用存储在Windows证书管理器中的证书 - How to use certificate stored in windows certificates manager using python Windows 代码签名证书信任期 - Windows Code Signing Certificate Trust period
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM