Git Clone 使用 Watt/Steam++ 加速时报证书错误的原因与解决方法

1. 问题现象

执行:

bash 复制代码
git clone https://github.com/PX4/PX4-Autopilot.git

报错:

text 复制代码
fatal: 无法访问 'https://github.com/PX4/PX4-Autopilot.git/':server certificate verification failed. CAfile: none CRLfile: none

这类错误说明 Git 在访问 GitHub 的 HTTPS 地址时,无法完成服务器证书校验。

2. 根本原因

本次问题不是 PX4 仓库的问题,也不是 GitHub 仓库地址写错。

原因是使用了 Watt/Steam++ 加速器后,HTTPS 流量会经过本地加速/代理服务。该服务会使用自己的本地根证书,例如:

text 复制代码
SteamTools Certificate
BeyondDimension

如果 Linux/Ubuntu 系统没有信任这个证书,Git 就会拒绝连接,并报证书校验失败。

本机证书文件位置为:

bash 复制代码
/home/sg/.local/share/Steam++/Plugins/Accelerator/SteamTools.Certificate.cer
/home/sg/.local/share/Steam++/Plugins/Accelerator/SteamTools.Certificate.pfx

其中 .cer 是系统信任链更常用的证书格式,.pfx 通常是包含证书和私钥的证书包。

3. 推荐解决方法:安装到系统 CA

推荐把 Watt/Steam++ 的证书安装到 Ubuntu/Linux 的系统证书库。

已经准备好的脚本:

bash 复制代码
~/bin/install-steamtools-system-ca.sh

执行:

bash 复制代码
~/bin/install-steamtools-system-ca.sh

脚本内容做了这些事情:

text 复制代码
1. 检查 SteamTools.Certificate.cer 是否存在且有效
2. 安装到 /usr/local/share/ca-certificates/steamtools.crt
3. 删除之前错误的空证书 /usr/local/share/ca-certificates/steam-plus.crt
4. 执行 sudo update-ca-certificates --fresh
5. 让 Git 回到使用系统证书库

注意:这个步骤需要输入当前 Linux 用户的 sudo 密码。

4. 手动修复命令

如果不使用脚本,也可以手动执行:

bash 复制代码
sudo install -m 0644 \
  /home/sg/.local/share/Steam++/Plugins/Accelerator/SteamTools.Certificate.cer \
  /usr/local/share/ca-certificates/steamtools.crt

sudo rm -f /usr/local/share/ca-certificates/steam-plus.crt
sudo update-ca-certificates --fresh

git config --global --unset http.sslCAInfo 2>/dev/null || true
git config --global http.sslVerify true

然后重新 clone:

bash 复制代码
cd ~/SG/learn-sg
git clone https://github.com/PX4/PX4-Autopilot.git

5. 验证方法

查看 Git 的 SSL 配置:

bash 复制代码
git config --show-origin --get-regexp 'http\.ssl'

正常情况下可以只看到:

text 复制代码
http.sslverify true

或者没有额外的 http.sslCAInfo 配置,让 Git 使用系统默认证书库。

查看系统是否安装了证书:

bash 复制代码
ls -l /usr/local/share/ca-certificates/steamtools.crt

查看证书内容:

bash 复制代码
openssl x509 \
  -in /usr/local/share/ca-certificates/steamtools.crt \
  -noout -subject -issuer -dates

预期能看到类似:

text 复制代码
subject=CN = SteamTools Certificate, OU = Technical Department, O = BeyondDimension, C = CN
issuer=CN = SteamTools Certificate, OU = Technical Department, O = BeyondDimension, C = CN

6. 备选方法:只给 Git 配置信任证书

如果当前环境不能使用 sudo,可以使用 Git 用户级 CA 配置。

已经准备好的脚本:

bash 复制代码
~/bin/fix-watt-git-ca.sh

使用 .cer

bash 复制代码
~/bin/fix-watt-git-ca.sh \
  /home/sg/.local/share/Steam++/Plugins/Accelerator/SteamTools.Certificate.cer

使用 .pfx

bash 复制代码
~/bin/fix-watt-git-ca.sh \
  /home/sg/.local/share/Steam++/Plugins/Accelerator/SteamTools.Certificate.pfx

这个方法会生成:

bash 复制代码
~/.config/git/certs/ca-bundle-with-watt.crt

并配置:

bash 复制代码
git config --global http.sslCAInfo ~/.config/git/certs/ca-bundle-with-watt.crt
git config --global http.sslVerify true

这种方法只影响 Git,不影响 curl、apt、Python、Node.js 等其他程序。

7. 不推荐的方法

不要长期使用:

bash 复制代码
git config --global http.sslVerify false

也不要长期使用:

bash 复制代码
GIT_SSL_NO_VERIFY=true git clone https://github.com/PX4/PX4-Autopilot.git

这会关闭 HTTPS 证书校验,虽然可能临时绕过错误,但会降低安全性。

8. 本次排查结论

本次排查中发现:

text 复制代码
/usr/local/share/ca-certificates/steam-plus.crt

是一个 0 字节空文件,所以系统实际上没有导入 Watt/Steam++ 的有效证书。

最终通过安装:

text 复制代码
SteamTools.Certificate.cer

并运行:

bash 复制代码
sudo update-ca-certificates --fresh

解决了 Git clone 时报:

text 复制代码
server certificate verification failed

的问题。

相关推荐
Sayai7 小时前
Elasticsearch 日志索引设计:按小时切分 + 小时内 Rollover 兜底(ILM 实战,附完整脚本)
大数据·elasticsearch·搜索引擎
Elasticsearch7 小时前
生产环境向量搜索的一个设置:vectordb_document 模式如何自动调优 Elasticsearch
elasticsearch
【赫兹威客】浩哥8 小时前
基于SpringBoot+Vue3的舆情文本分析系统|Elasticsearch检索+情感分析+话题热度追踪 毕设项目
spring boot·elasticsearch·课程设计
慕容引刀8 小时前
或许你真的需要这个Git神器:让团队提交文案终于对齐了
人工智能·git·vscode·自然语言处理·github
天涯明月19938 小时前
ray深度研究报告
大数据·人工智能·分布式·ray
jjh+++(求关注版)9 小时前
git-命令速查清单
git
玉&心9 小时前
在grafana中加入elasticsearch的日志dashboard
elasticsearch·grafana
迪康coolmu9 小时前
企业文件外发防泄漏实践:从通道封堵到三层全链路管控
大数据·运维·网络·人工智能·安全·阿里云
Elasticsearch10 小时前
让大模型思考,让小模型执行:在 Elastic Workflows 中拆分 LLM 成本
elasticsearch
数字融合17 小时前
透明化地铁线视频孪生综合监控项目技术
大数据·人工智能·virtualenv