红联Linux门户
Linux帮助

gitlab同步代码时https证书错误

发布时间:2016-12-19 09:42:11来源:linux网站作者:feiniao8651
OS:Ubuntu 14.04
 
最近在用 repo从gitlab上同步代码,执行repo init总是会有报错:
curl: (60) SSL certificate problem: unable to get local issuer certificate  
More details here: http://curl.haxx.se/docs/sslcerts.html  
curl performs SSL certificate verification by default, using a "bundle"  
of Certificate Authority (CA) public keys (CA certs). If the default  
bundle file isn't adequate, you can specify an alternate file  
using the --cacert option.  
If this HTTPS server uses a certificate signed by a CA represented in  
the bundle, the certificate verification probably failed due to a  
problem with the certificate (it might be expired, or the name might  
not match the domain name in the URL).  
If you'd like to turn off curl's verification of the certificate, use  
the -k (or --insecure) option.  
 
搜索了一圈资料,没找到好的解决方法,有一个方法是从http://curl.haxx.se/ca/cacert.pem下载证书,但是并没找到该怎么用这个下载的证书文件。
正在自己挠头的时刻,忽然看到上面日志提到的url:http://curl.haxx.se/docs/sslcerts.html,抱着一试的心态,还真找到了我想要的证书使用方法。
这个链接里也提到了,证书是作为网站合法性验证的工具,应该是由于我的本地证书不完整,或者是已经过期,无法验证gitlab的合法性,所以需要有一个最新的证书文件。将cacert.pem下载到本地后,只要执行export CURL_CA_BUNDLE={cacert.pem文件路径},此时再去做repo init,就不再报证书的错误了。
 
repo sync时出现类似于:
curl: (22) The requested URL returned error: 401 Unauthorized
这种401认证错误的问题,也可以用以上的方法解决。
 
本文永久更新地址:http://www.linuxdiyf.com/linux/27034.html