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仓库的管理非常方便.

相关推荐
ESDWAN7 小时前
海外系统偶尔打不开,怎么区分 DNS 异常与网络连接故障?
tcp/ip·https
昂好的day8 小时前
VisionMaster 通信模块实战(上):Modbus、TCP 收发、协议组装解析
开发语言·网络·网络协议·tcp/ip·c#
IOT那些事儿11 小时前
Git报错:Could not get HEAD hash
git·hash·head
2501_9159214311 小时前
iOS应用耗电测试:使用Energy Log、Keymob和Instruments进行性能监控与能源消耗分析
android·ios·小程序·https·uni-app·iphone·webview
盛世宏博智慧档案12 小时前
算力机房多协议融合:Modbus TCP 温湿度变送器与 SNMP 设备混合组网方案
网络·网络协议·tcp/ip·传感器·温湿度
杜哥无敌13 小时前
Git Bash + acme.sh 实现 SSL 证书自动续签(完整指南)
git·bash·ssl
川石课堂软件测试14 小时前
涨薪技术|0到1学会性能测试第9课-HTTP响应统计
数据库·功能测试·网络协议·http·kubernetes·单元测试·测试用例
可信时间戳15 小时前
原创作品怎么申请版权?草稿、定稿、已发布、已授权,四个阶段四个做法
网络协议·http·https
话梅姐姐呀15 小时前
TCP/IP 架构各层的协议概述
人工智能·物联网·网络协议·tcp/ip·iot
husterlichf16 小时前
网关、掩码、子网、vlan、交换机
网络·网络协议