如何在 git clone 时跳过 SSL 证书验证
问题:
运行 git clone 时,你看到类似这样的错误消息
git_clone_ssl_error.txt
Cloning into 'MyProject'...
fatal: unable to access 'https://gitlab.mydomain.com/projects/MyProject.git': server certificate verification failed. CAfile: /etc/ssl/certs/ca-certificates.crt CRLfile: none解决方案
快速解决方案是在前面添加
git_ssl_no_verify.sh
GIT_SSL_NO_VERIFY=true到 git clone 命令,例如:
git_clone_with_ssl_skip.sh
GIT_SSL_NO_VERIFY=true https://gitlab.mydomain.com/projects/MyProject.git注意跳过 SSL 验证有安全风险,因此修复此问题的正确方法是适当更新 CA 证书(类似 sudo apt install ca-certificates),但这有时不可行,因为并非任何过时的计算机都能轻松更新。
If this post helped you, please consider buying me a coffee or donating via PayPal to support research & publishing of new posts on TechOverflow