Bootstrap

git常见问题汇总

问题1:fatal: unable to access 'xxx.git/': SSL certificate problem: unable to get local issuer certificate

遇到这个问题,先检查一下自己是否有开启代理或者vpn,可能是由于代理或者vpn导致的无法连接。该问题是由于没有配置信任的服务器HTTPS验证,无法获取本地颁发者证书。默认,cURL被设为不信任任何CAs,就是说,它不信任任何服务器验证。

解决方案:

有两种常见的解决方案,第一种是关闭ssl校验,第二种是配置使用本地的ssl证书,具体步骤参考下面的代码块:

// 方法一:关闭ssl校验
git config --global http.sslVerify false

// 方法二:配置certificate
// 1.下载openssl
// 2.配置环境变量,将bin加入环境变量中
// 3.生成私钥文件
openssl genrsa -des3 -out localhost.key 2048
// 4.去除私钥密码
openssl rsa -in localhost.key -out localhost.key
// 5.生成证书
openssl req -new -key localhost.key -out localhost.csr
openssl x509 -req -days 36500 -in localhost.csr -signkey localhost.key -out localhost.crt
// 6.git指定certificate
git config –system http.sslCAPath /absolute/path/to/git/certificates
;