Can't access Bitbucket Server with Git - Issuer certificate is invalid
The following message is displayed when trying to
push to a Bitbucket Server repository:
error: Issuer certificate is invalid. while accessing https://<USERNAME>@<BITBUCKET_HOST>:8443/ABC/test.git/info/refs fatal: HTTP request failed
- Bitbucket Server/DC 7+
You just added a self signed certificate to Bitbucket Server and now your users are getting errors:
fatal: unable to access 'https://<username>@<bitbucket_server>:<port>/<context>/scm/<project>/<repository>/': server certificate verification failed. CAfile: /etc/ssl/certs/ca-certificates.crt CRLfile: none
The Bitbucket Server certificate is not trusted by the
A very good article on the subject can be found here on Stack Overflow. In summary, when you use a self-signed certificate Git doesn't trust the certificate that is being sent to it. You can fix this in three ways:
- On each client system run:
git config --global http.sslVerify false
- Install the self-signed server certificate on the git client machine.
- Review if antivirus is replacing SSL certs in SSL connections.
Please be advised disabling SSL verification globally might be considered a security risk and should be implemented only temporarily
To be able to use a self-signed certificate do the following:
- Copy the Bitbucket Server instance's
certificate.pemfile to the git client's host. Instructions about this can be found on Secure Bitbucket with Tomcat using SSL document.
Convert the file into the
openssl x509 -in certificate.pem -out certificate.crt
Now allow git to use this certificate by changing the user's git configuration file:
git config http.sslcainfo certificate.crt
All commands must be executed in the
<PATH> where the certificate was copied to.
Use a certificate that is signed by a Certificate Authority. These certificates are automatically trusted.
Note that the complete certificate chain should be included (include any intermediate certs up to the trusted root CA).
If only the end-user certificate is included, Git clients will still not be able to verify the certificate.
Antivirus installed in the client machine can also cause this issue. As an example Symantec Endpoint Protection has a feature that replaces all SSL certificates in a connection, which leads up the SSL connection not being trusted. In scenarios like this one, this feature must be disabled. You may need to reach out to your IT department for that assistance.