git clone报错:SSL certificate problem: unable to get local issuer certificate
上述报错的完整信息是:
Cloning into 'test'...
fatal: unable to access 'https://github.com/xxxx/xxxx.git/': SSL certificate problem: unable to get local issuer certificate
该报错表示 Git 在使用 HTTPS 协议克隆仓库时,无法验证 GitHub 的 SSL 证书。这通常是因为你的系统缺少受信任的根证书或 Git 的 CA 证书包配置不正确。
解决方案:告诉git使用系统的证书
在git bash执行以下命令:
git config --global http.sslVerify true
git config --global http.sslBackend schannel
注意,这里最好使用关键字global,如果使用system可能会报错没有权限
error: could not lock config file D:/Program Files/Git/etc/gitconfig: Permission
denied
类似地,手动更新git 的证书包,也可能会报一样的错:没有权限
其中,手动更新git证书包的方法:从 curl 官方网站 下载最新的 cacert.pem 文件,并重命名为
ca-bundle.crt,放入git的目录:git\mingw64\ssl 下