git-repo系列教程(3) git-repo https证书认证问题

文章目录

问题描述

在使用git repo 同步仓库时,发现不能同步,出现如下提示错误:

bash 复制代码
    % Total    % Received % Xferd  Average Speed   Time    Time     Time  Current
    Dload  Upload   Total   Spent    Left  Speed
     0     0    0     0    0     0      0      0 --:--:-- --:--:-- --:--:--     0
     0     0    0     0    0     0      0      0 --:--:-- --:--:-- --:--:--     0

curl: (60) SSL certificate problem: self-signed certificate in certificate chain, More details here: https://curl.se/docs/sslcerts.html.
curl failed to verify the legitimacy of the server and therefore could not establish a secure connection to it. 
To learn more about this situation and how to fix it, please visit the web page mentioned above.

根据提示,阅读网页: https://curl.se/docs/sslcerts.html

发现最好的办法是把证书下载下来,设置环境变量.

解决步骤

1.下载证书

bash 复制代码
# -k 跳过证书验证
# -w %{certs} 抽取服务器端的证书
# > cacert.pem 把证书存储到文件中
curl -k  -w %{certs} https://xxx/ > cacert.pem

#证书内容在 "-----BEGIN CERTIFICATE-----"和"-----END CERTIFICATE-----"
#删除其他内容,只保留
#"-----BEGIN CERTIFICATE-----"
#xxxxx
#xxxx
#"-----END CERTIFICATE-----"

2.测试证书是否正常

bash 复制代码
#指定证书文件
curl --cacert cacert.pem -w %{certs} https://xxxx/
#发现可以下载页面

3.设置环境变量

bash 复制代码
#把证书文件放在家目录下
mkdir ~/cacert
mv cacert.prm ~/cacert/
vim ~/.bashrc
	export CURL_CA_BUNDLE="/home/lin/cacert/cacert.prm"
source ~/.bashrc
#注意'CURL_CA_BUNDLE'需要设置绝对路径

总结

这个问题在网上很少遇到,搜索了几天也没有搜索到答案,看一下提示文档很容易解决了.

git-repo是android系统代码使用的源代码管理工具,不做安卓的很少使用,国内资料相对也很少.但是这个工具非常强大,对大型项目多个git仓库的管理非常方便.

相关推荐
小李独爱秋10 分钟前
计算机网络经典问题透视:蜂窝网络切换如何“扼杀”你的TCP连接?
网络·网络协议·tcp/ip·计算机网络·php·信息与通信
路由侠内网穿透.29 分钟前
本地部署代码托管解决方案 Gitea 并实现外部访问( Windows 版本)
运维·服务器·网络协议·gitea
stevenzqzq3 小时前
git 常用操作
大数据·git
Curvatureflight5 小时前
Git工作流最佳实践:从混乱到优雅
git
yixvxi5 小时前
RFC 8659:DNS CAA资源记录
服务器·https·ssl
北京耐用通信5 小时前
耐达讯自动化Profinet转Devicenet网关:精细化工行业的“协议融合利器”
人工智能·物联网·网络协议·自动化·信息与通信
三水不滴5 小时前
计算机网络核心网络模型
经验分享·笔记·tcp/ip·计算机网络·http·https
wu~9705 小时前
GitHub永不遗忘,使用git push -f来覆盖的提交依旧保留
git·github
云小逸6 小时前
【nmap源码学习】 Nmap 源码深度解析:nmap_main 函数详解与 NSE 脚本引擎原理
网络协议·学习·安全
迎仔6 小时前
03-网络协议基础详解:数字世界的交通规则与语言
网络·网络协议