gpt4 book ai didi

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

转载 作者:IT王子 更新时间:2023-10-29 01:09:25 25 4
gpt4 key购买 nike

使用 Git,有没有办法告诉它接受自签名证书?

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

当我第一次尝试在那里创建 repo 时:

git push origin master -f

我得到错误:

error: Cannot access URL     
https://the server/git.aspx/PocketReferences/, return code 22

fatal: git-http-push failed

最佳答案

永久接受特定证书

试试 http.sslCAPathhttp.sslCAInfoAdam Spiers's answer给出了一些很好的例子。这是该问题最安全的解决方案。

为单个 git 命令禁用 TLS/SSL 验证

尝试使用适当的配置变量将 -c 传递给 git,或者使用 Flow's answer :

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

为所有存储库禁用 SSL 验证

可以全局停用 ssl 验证。 强烈建议不要这样做,但为了完整性而提到:

git config --global http.sslVerify false # Do NOT do this!

git 中有很多 SSL 配置选项。来自 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 配置选项:

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 - 如何让 git 接受自签名证书?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/11621768/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com