How to Fix: "SSL Certificate Problem: Self-Signed Certificate" in Git & Docker



This is one of the most common "Security vs. Productivity" errors. You’re trying to pull a private image or clone a repo, and your system blocks you because it doesn't trust the security certificate.

The Error: fatal: unable to access 'https://github.com/repo.git/': SSL certificate problem: self signed certificate in certificate chain


Why is this happening?

Your company or home network is likely using a "Self-Signed" SSL certificate for security monitoring. Git and Docker are designed to be secure by default, so they block these connections because they can't verify the "Chain of Trust."

❌ The "Bad" Way (Don't do this in Production!)

You will see people online telling you to just disable SSL verification:

git config --global http.sslVerify false

Why avoid this? This turns off security entirely, making you vulnerable to "Man-in-the-Middle" attacks. It's okay for a 2-minute test, but never leave it this way.

✅ The "Secure" Fix (The DevSecOps Way)

Instead of turning security off, tell your system to trust your specific certificate.

1. Download the Certificate

Export the .crt file from your browser (click the lock icon next to the URL) or get it from your IT department.

2. Update Git to use the Certificate

Point Git to your certificate file:

git config --global http.sslcainfo /path/to/your/certificate.crt

3. Update Docker (on Linux)

If Docker is failing, move the certificate to the trusted folder:

sudo mkdir -p /usr/local/share/ca-certificates/
sudo cp my-cert.crt /usr/local/share/ca-certificates/
sudo update-ca-certificates

Pro Tip: Use a Secret Scanner

While you're fixing security errors, make sure you aren't accidentally pushing passwords into your code! Tools like TruffleHog or git-secrets can scan your repo and stop you before you commit a major security leak.


No comments:

Post a Comment

How to Fix: "SSL Certificate Problem: Self-Signed Certificate" in Git & Docker

This is one of the most common "Security vs. Productivity" errors. You’re trying to pull a private image or clone a repo, and your...