git 如何解决 SSL 证书:从 github 克隆 repo 时的自签名证书?
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/39004750/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
How to solve SSL certificate: self signed certificate when cloning repo from github?
提问by BRabbit27
I just installed git for windows and tried to clone glew's repo like this
我刚刚为 windows 安装了 git 并尝试像这样克隆 glew 的 repo
$ git clone https://github.com/nigels-com/glew.git
But I got the following error
但我收到以下错误
Cloning into 'glew'...
fatal: unable to access 'https://github.com/nigels-com/glew.git/': SSL certificate problem: self signed certificate
I've seen people running into this problem and some possible workarounds.
我见过人们遇到这个问题和一些可能的解决方法。
First try
第一次尝试
$ git -c http.sslVerify=false clone https://github.com/nigels-com/glew.git
Cloning into 'glew'...
fatal: unable to access 'https://github.com/nigels-com/glew.git/': Empty reply from server
Second try
第二次尝试
$ git config --global http.sslVerify false
$ git clone https://github.com/nigels-com/glew.git
Cloning into 'glew'...
fatal: unable to access 'https://github.com/nigels-com/glew.git/': Empty reply from server
Then I checked for http.sslcainfo
entry in the config files
然后我检查http.sslcainfo
了配置文件中的条目
$ git config --system --list
credential.helper=manager
$ git config --global --list
https.proxy=<proxy-address>
http.sslverify=false
System and global config files does not have that entry. So I tried the following which I don't know what file is reading and try to unset it.
系统和全局配置文件没有该条目。所以我尝试了以下我不知道正在读取什么文件并尝试取消设置的方法。
$ git config --list
core.symlinks=false
core.autocrlf=true
core.fscache=true
color.diff=auto
color.status=auto
color.branch=auto
color.interactive=true
help.format=html
http.sslcainfo=C:/Program Files/Git/mingw64/ssl/certs/ca-bundle.crt
diff.astextplain.textconv=astextplain
rebase.autosquash=true
credential.helper=manager
http.sslverify=false
$ git config --unset http.sslcainfo
fatal: not in a git directory
Tried with global and system
试过全局和系统
$ git config --global --unset http.sslcainfo
$ git clone https://github.com/nigels-com/glew.git
Cloning into 'glew'...
fatal: unable to access 'https://github.com/nigels-com/glew.git/': SSL certificate problem: self signed certificate
$ git config --system --unset http.sslcainfo
error: could not lock config file C:\Program Files\Git\mingw64/etc/gitconfig: Permission denied
error: could not lock config file C:\Program Files\Git\mingw64/etc/gitconfig: Invalid argument
I still cannot clone that github repo. Any other idea I can try to fix this problem? What am I missing?
我仍然无法克隆那个 github 存储库。我可以尝试解决此问题的任何其他想法吗?我错过了什么?
采纳答案by WPrecht
You're overthinking this. Git requires the SSH key to do the transfer. In order for this to work, you need an account on GitHub. If you have already generated an SSH key pair for other sites, you can reuse that one. All you need to do is log into GitHub.com and copy it there in your settings panel.
你想多了。Git 需要 SSH 密钥才能进行传输。为了使其工作,您需要在 GitHub 上有一个帐户。如果您已经为其他站点生成了 SSH 密钥对,则可以重复使用该密钥对。您需要做的就是登录 GitHub.com 并将其复制到您的设置面板中。
If you don't have an account, make one. If you haven't generated a key pair, that's simple:
如果您没有帐户,请创建一个。如果您还没有生成密钥对,那很简单:
ssh-keygen -t rsa -C "[email protected]"
Then copy the key to your settings in GitHub.com
然后将密钥复制到您在 GitHub.com 中的设置
There are instructions all over the place on how to do this in various ways. I have a self-signed cert and I was able to clone the repo you listed.
到处都有有关如何以各种方式执行此操作的说明。我有一个自签名证书,并且能够克隆您列出的存储库。