Sep 6, 2022 1 min read

Cloning Git repositories with self-signed certificates or Custom CAs

Cloning Git repositories with self-signed certificates or Custom CAs

The problem

When working in an environment that is either a private enterprise, one with its own internal PKI, or even your home lab you may run into this issue when working with git. Since there is not an external CA to validate your git address for HTTPS you will run into this error.

- [fatal: unable to access 'PATH_TO_REPO': SSL certificate problem: self signed certificate in certificate chain]

All this means is that when trying to access the repository to clone it your git client was unable to validate the certificate. Sometimes on Windows or even Linux, your git client will use its own CA repository to validate against and it makes it difficult to configure.

Workaround

There are a few ways to get around this.

Method 1 - Single-use git clone with SSL turned off

git -c http.sslVerify=false clone <repository-name>

Method 2 - Globally turn off SSL for git

git config --global http.sslVerify false

Only disable git globally in a test environment. This is considered a large security risk.

Solution

Like it was stated above on some git applications there will need to be configurations made specifically for that use. This is the general way to remedy this issue correctly.

This only works for servers that have certificates from a CA. This will not work for self-signed.

  1. Import your CA file into your local trusted ca store.
  2. Input the following command.
git config --system http.sslCAPath /path/to/cacerts
Great! You’ve successfully signed up.
Welcome back! You've successfully signed in.
You've successfully subscribed to Nimbus Code.
Your link has expired.
Success! Check your email for magic link to sign-in.
Success! Your billing info has been updated.
Your billing was not updated.