Especially with private git repositories that may be self-signed or have private CA, you may get the following error from the git client after a certificate has been updated:
fatal: unable to access 'https://git.mycompany.com/myuser/myrepo.git/': server certificate verification failed. CAfile: /etc/ssl/certs/ca-certificates.crt CRLfile: none
This means that the git client cannot verify the integrity of the certificate chain or root. The proper way to resolve this issue is to make sure the certificate from the remote repository is valid, and then added to the client system.
Do not take the shortcut of using environment variables or git config to suppress ssl verification.
Update list of public CA
The first thing I would recommend is to simply update the list of root CA known to the system as show below.
# update CA certificates sudo apt-get install apt-transport-https ca-certificates -y sudo update-ca-certificates
This may help if you are dealing with a system that has not been updated for a long time, but of course won’t resolve an issue with private certs.
Fetch certificates, direct connection
openssl s_client -showcerts -servername git.mycompany.com -connect git.mycompany.com:443 </dev/null 2>/dev/null | sed -n -e '/BEGIN\ CERTIFICATE/,/END\ CERTIFICATE/ p' > git-mycompany-com.pem
Fetch certificates, web proxy
# install socat sudo apt-get install socat -y # listen locally on 4443, send traffic through squid "squidhost" socat TCP4-LISTEN:4443,reuseaddr,fork PROXY:squidhost:git.mycompany.com:443,proxyport= 3128
openssl s_client -showcerts -servername git.mycompany.com -connect 127.0.0.1:4443 </dev/null 2>/dev/null | sed -n -e '/BEGIN\ CERTIFICATE/,/END\ CERTIFICATE/ p' > git-mycompany-com.pem
Add certificate to local certificate list
cat git-mycompany-com.pem | sudo tee -a /etc/ssl/certs/ca-certificates.crt
git config --global http."https://git.mycompany.com/".sslCAInfo ~/git-mycompany-com.pem
[http "https://git.mycompany.com/"] sslCAInfo = /home/user/git-mycompany-com.pem
Avoid workarounds
git config --global http.sslverify false export GIT_SSL_NO_VERIFY=true
git config --global http.proxy http://mysquid:3128 GIT_SSL_NO_VERIFY=true git clone https://git/user/repo.git