如何解决SSL证书:从github克隆repo时自签名证书?

BRa*_*t27 13 git ssl github

我刚刚为windows安装了git并试图像这样克隆glew的repo

$ git clone https://github.com/nigels-com/glew.git
Run Code Online (Sandbox Code Playgroud)

但是我得到了以下错误

Cloning into 'glew'...
fatal: unable to access 'https://github.com/nigels-com/glew.git/': SSL certificate problem: self signed certificate
Run Code Online (Sandbox Code Playgroud)

我见过人们遇到这个问题和一些可能的解决方法.

第一次尝试

$ 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
Run Code Online (Sandbox Code Playgroud)

第二次尝试

$ 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
Run Code Online (Sandbox Code Playgroud)

然后我检查http.sslcainfo了配置文件中的条目

$ git config --system --list
credential.helper=manager

$ git config --global --list
https.proxy=<proxy-address>
http.sslverify=false
Run Code Online (Sandbox Code Playgroud)

系统和全局配置文件没有该条目.所以我尝试了以下内容,我不知道正在阅读什么文件并尝试取消设置.

$ 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
Run Code Online (Sandbox Code Playgroud)

尝试全球和系统

$ 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
Run Code Online (Sandbox Code Playgroud)

我仍然无法克隆那个github repo.我可以尝试解决这个问题吗?我错过了什么?

小智 13

您可以使用以下命令禁用 SSL 验证

git config --global http.sslVerify false
Run Code Online (Sandbox Code Playgroud)


WPr*_*cht -11

你想太多了。Git 需要 SSH 密钥才能进行传输。为了实现此功能,您需要在 GitHub 上拥有一个帐户。如果您已经为其他站点生成了 SSH 密钥对,则可以重复使用该密钥对。您所需要做的就是登录 GitHub.com 并将其复制到您的设置面板中。

如果您没有帐户,请创建一个。如果您还没有生成密钥对,那很简单:

ssh-keygen -t rsa -C "youremail@somewhere.com"
Run Code Online (Sandbox Code Playgroud)

然后将密钥复制到 GitHub.com 中的设置

到处都有关于如何以各种方式执行此操作的说明。我有一个自签名证书,并且我能够克隆您列出的存储库。

  • 错误,SSL 与 SSH 无关。 (15认同)
  • 是的,这是错误的。这并不能解决问题,而是使用不同的技术来获取存储库。 (3认同)
  • 错误的答案,很遗憾这个答案在这里被接受。 (2认同)