others-how to solve git fatal: unable to access: SSL certificate problem: self signed certificate ?
Problem
When we git clone a repository from our private git server like gitlab or github enterprise , sometimes ,we get this error:
➜ git clone https://10.1.1.1/bswen/testrepo1.git
Cloning into 'testrepo1'...
fatal: unable to access 'https://10.1.1.1/bswen/testrepo1.git/': SSL certificate problem: self signed certificate
Environment
- MacOS git version 2.21.1 (Apple Git-122.3)
Reason
Our git server use a self-signed private ssl certificate, so that’s the problem, git client can not verify this certificate.
Solution
We should disable the git client’s SSL certificate verification as follows:
git config --local http.sslVerify false
Or , if you want to set this configuration globally ,you can set as follows:
git config --global http.sslVerify false
You can verify the settings as follows:
git config --list --local
One more thing
Thanks to this answer about git configurations in stackoverflow:
To understand Git configuration, you should know that:
Git configuration can be stored at three different levels. Each level overrides values at the previous level.
1. System level (applied to every user on the system and all their repositories)
- to view,
git config --list --system
(may needsudo
) - to set,
git config --system color.ui true
- to edit system config file,
git config --edit --system
2. Global level (values specific personally to you, the user).
- to view,
git config --list --global
- to set,
git config --global user.name xyz
- to edit global config file,
git config --edit --global
3. Repository level (specific to that single repository)
- to view,
git config --list --local
- to set,
git config --local core.ignorecase true
(--local
optional) - to edit repository config file,
git config --edit --local
(--local
optional)
It works!