Git:HTTP请求失败

编程入门 行业动态 更新时间:2024-10-09 08:30:43
本文介绍了Git:HTTP请求失败的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧! 问题描述

$ b

git status 仅列出一项:master

p>

git remote -v 列出了两个条目到同一个地址:一个用于提取,一个用于推送

但是当我执行 git remote show origin 或其他操作时,例如 fetch ,我得到:

错误:访问https时:... 致命错误:HTTP请求失败

我在代理之后,但是它在我的.gitconfig(sslVerify = no)中设置,克隆是好的,我不认为问题来自于此。

但是...我的操作系统(CentOS)已被重新安装。

<如果您使用 https:而不是 git: $ c>作为你的克隆,它可能会在CA证书上出现问题,即你没有中间证书的副本来验证你的SSL连接。我遇到过几次不同的场合。通常使用基于Debian的Linux发行版。尝试

git config --global http.sslVerify false

,然后再次克隆。如果克隆工作,那就是发生了什么。然而,这是一个不好的解决方案,因为当然会关闭SSL验证,这使得使用HTTPS毫无意义,并且容易受到中间人攻击。

你需要做的是下载CA Certificates软件包,以查看你在Linux下的任何操作系统(以及Debian / Ubuntu),它可能类似于

 then 

git config --global http.sslVerify true git config --global http.sslCAinfo / etc / ssl / certs / ca-证书.crt

尽管您的证书文件路径可能会因操作系统版本而有所不同。

这应该起作用。

I have a remote repository with HTTPS access.

git status lists only one entry: master

git remote -v lists two entries to the same address: one for fetch, one for push

But when I do git remote show origin, or other operations, like fetch, I get :

error: while accessing https:... fatal: HTTP request failed

I am behind a proxy, but as it is set in my .gitconfig (sslVerify = no) and the cloning is OK, I don't think the problem comes from that.

BUT... my OS (CentOS) has been reinstalled.

解决方案

If you're using https: rather than git: for your clone, it's possible that it's barfing on the CA certificate, i.e. you don't have a copy of the intermediate certificate to verify your SSL connection. I've run into this on a couple of different occasions. Usually with debian-based Linux distributions. Try

git config --global http.sslVerify false

and then the clone again. If the clone works, that's what's happening. However this is a bad solution, as of course turns off SSL verification, which makes using HTTPS somewhat pointless, and leaves you vulnerable to man-in-the-middle attacks.

What you need to do is download the CA Certificates package for whatever OS you're on, under Linux (well Debian/Ubuntu) it'll probably be something like

apt-get install ca-certificates

then

git config --global http.sslVerify true git config --global http.sslCAinfo /etc/ssl/certs/ca-certificates.crt

although your path to your certificate file might be different depending on OS version.

This should get it working.

更多推荐

Git:HTTP请求失败

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

发布评论

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

>www.elefans.com

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