windows:curl: (60) schannel: SEC_E_UNTRUSTED_ROOT (0x80090325)

发布于:2025-03-10 ⋅ 阅读:(16) ⋅ 点赞:(0)

1. git update-git-for-windows 报错

Lenovo@LAPTOP-EQKBL89E MINGW64 /d/YHProjects/omni-channel-recon-dev (master)
$ git update-git-for-windows
curl: (60) schannel: SEC_E_UNTRUSTED_ROOT (0x80090325) - 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 webpage mentioned above.
  • 操作:windows环境使用git update-git-for-windows从我自己的gitee仓库更新代码。
  • 报错信息:curl 在尝试与服务器建立安全连接时,无法验证服务器的 SSL 证书。这可能是因为服务器使用了自签名证书,或者证书链中的某个证书不被客户端信任。
    简而言之:我的本机(即本地 Git 客户端)拒绝验证远程服务器的 SSL 证书

2. 解决方案

2.1. 更新 CA 证书库

Windows操作系统通常会通过Windows Update自动更新根证书。
确保我的操作系统或 Git 客户端的 CA 证书库是最新的,这样可能会包含远程服务器证书的签发机构。

但是我的Windows11确实已经是最新版的了,并且我想起来了,我昨天下班的时候更新了一下Windows,下班之前我都还能正常用git拉项目,更新之后就不行了

至于去使用gitee的CA证书,于我而言就不现实了,我根本拿不到。

2.2. 使用 SSH 连接(推荐)

使用 SSH 而不是 HTTPS 来克隆或更新代码。SSH 方式不需要依赖 SSL 证书验证,通常更安全。

  1. 生成SSH密钥

    ssh-keygen -t rsa -b 4096 -C "your_email@example.com"
    
  2. 查看公钥并复制

    cat ~/.ssh/id_rsa.pub
    
  3. 将复制的公钥放到个人——设置——SSH公钥下

  4. 重新clone,但是选择仓库的ssh地址来进行克隆

    git clone git@gitee.com:username/repo.git
    

2.3 禁用 SSL 验证(不推荐)

不推荐的原因如下:

  1. 虽然可以临时禁用 SSL 验证来绕过这个问题,但这会降低安全性,因为它会使你的连接容易受到中间人攻击。
  2. 压根不起作用,临时禁用都不行,还是报错,艹
git config --global http.sslVerify false

2.4 使用pull不使用update

很离谱,上周按照2.2修改后都用了好几天,结果这周一来,又是这个b报错。

Lenovo@LAPTOP-EQKBL89E MINGW64 /d/YHProjects/omni-channel-recon-dev (master)
$ git update-git-for-windows
curl: (60) schannel: SEC_E_UNTRUSTED_ROOT (0x80090325) - 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 webpage mentioned above.

但是我用pull,也能用push推送代码又能正常更新。

git pullgit push 是 Git 仓库的操作,通常不会涉及 SSL 证书验证问题。
git update-git-for-windows 是通过 curl 下载更新,因此会触发 SSL 证书验证。

git pull origin master