我如何让git接受自签名证书?

编程入门 行业动态 更新时间:2024-10-07 22:25:14
本文介绍了我如何让git接受自签名证书?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧! 问题描述

使用Git,是否有办法让它接受一个自签名证书?

Using Git, is there a way to tell it to accept a self signed certificate?

我使用https服务器来托管git服务器,但现在证书是自签名的。

I am using an https server to host a git server but for now the certificate is self signed.

当我尝试第一次创建回购时:

When I try to create the repo there for the first time:

git push origin master -f

我得到这个错误:

error: Cannot access URL the server/git.aspx/PocketReferences/, return code 22 fatal: git-http-push failed

推荐答案

永久接受特定证书 。 亚当斯皮尔斯的回答给出了一些很好的例子。这是对这个问题最安全的解决方案。

To permanently accept a specific certificate

Try http.sslCAPath or http.sslCAInfo. Adam Spiers's answer gives some great examples. This is the most secure solution to the question.

用适当的配置变量尝试传递 -c 到 git ,或者使用流程的答案:

try passing -c to git with the proper config variable, or use Flow's answer:

git -c http.sslVerify=false clone example/path/to/git

禁用特定SSL验证repository

如果存储库完全在您的控制之下,您可以尝试:

To disable SSL verification for a specific repository

If the repository is completely under your control, you can try:

git config http.sslVerify false

全局禁用TLS(/ SSL)证书验证是一个非常不安全的做法。不要这样做。不要使用 - global 修饰符发出上述命令。

Disabling TLS(/SSL) certificate verification globally is a terribly insecure practice. Don't do it. Do not issue the above command with a --global modifier.

git 中有相当多的SSL配置选项。从 git config :

There are quite a few SSL configuration options in git. From the man page of git config:

http.sslVerify Whether to verify the SSL certificate when fetching or pushing over HTTPS. Can be overridden by the GIT_SSL_NO_VERIFY environment variable. http.sslCAInfo File containing the certificates to verify the peer with when fetching or pushing over HTTPS. Can be overridden by the GIT_SSL_CAINFO environment variable. http.sslCAPath Path containing files with the CA certificates to verify the peer with when fetching or pushing over HTTPS. Can be overridden by the GIT_SSL_CAPATH environment variable.

其他一些有用的SSL配置选项:

A few other useful SSL configuration options:

http.sslCert File containing the SSL certificate when fetching or pushing over HTTPS. Can be overridden by the GIT_SSL_CERT environment variable. http.sslKey File containing the SSL private key when fetching or pushing over HTTPS. Can be overridden by the GIT_SSL_KEY environment variable. http.sslCertPasswordProtected Enable git's password prompt for the SSL certificate. Otherwise OpenSSL will prompt the user, possibly many times, if the certificate or private key is encrypted. Can be overridden by the GIT_SSL_CERT_PASSWORD_PROTECTED environment variable.

更多推荐

我如何让git接受自签名证书?

本文发布于:2023-11-28 08:10:30,感谢您对本站的认可!
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
本文标签:证书   git

发布评论

评论列表 (有 0 条评论)
草根站长

>www.elefans.com

编程频道|电子爱好者 - 技术资讯及电子产品介绍!