git
self-signed certificate
SSL
troubleshooting
version control

How to make Git accept a self-signed certificate

Codemia Knowledge Hub ·

Tell Git to trust the certificate by pointing http.sslCAInfo at the .crt or .pem file, either globally or for one repository. If you cannot get the certificate, http.sslVerify false disables verification, but that removes the protection HTTPS gives you.

Why Git rejects self-signed certificates

A self-signed certificate is created and signed by its owner for personal or internal use, without verification by a third-party Certificate Authority (CA). They are common in testing, development, and internal networks because they are cheap and easy to create. Git validates certificates strictly, so by default it rejects them with "certificate verification failed" errors.

Step 1: Get the certificate file

You need the server's public certificate, usually a .crt or .pem file. Ask the server administrator for it if you do not already have it.

Step 2: Configure Git

Trust the certificate globally

To trust the certificate for every repository you work with, point Git at the file:

bash
   git config --global http.sslCAInfo /path/to/certificate.crt

This sets http.sslCAInfo to the path of your self-signed certificate, and Git uses it for all HTTPS connections.

Disable SSL verification

If getting the certificate is not feasible, you can turn off SSL verification entirely. Do not do this in production, though it can help in some development setups.

bash
git config --global http.sslVerify false

› WARNING: Disabling SSL verification can expose you to Man-In-The-Middle (MITM) attacks, as the authenticity of the server is no longer verified.

Limit the change to one repository

To change SSL behavior for a single repository only, run one of these from the repository root:

bash
git config http.sslCAInfo /path/to/certificate.crt

or

bash
git config http.sslVerify false

Only that repository then trusts the certificate or skips verification.

Step 3: Test the configuration

Clone, fetch, or push against the repository:

bash
git clone https://your-server.com/your-repo.git

If everything is configured correctly, the SSL verification errors are gone.

Certificates with intermediate CAs

If the certificate is part of a chain with intermediate certificates, Git needs the whole chain to validate the server certificate.

  1. Concatenate the certificates into a single file:
bash
   cat server.crt intermediate.crt root.crt > fullchain.crt
  1. Point http.sslCAInfo at the combined file:
bash
   git config --global http.sslCAInfo /path/to/fullchain.crt

Comparing the options

MethodDescriptionSecurity Considerations
Trust GloballySets a global configuration for Git to accept self-signed certificates.Safe if the certificate is controlled and trusted.
Disable SSL VerificationDisables SSL verification entirely.Risky, shouldn't be used in production scenarios.
Repository-Specific ConfigurationApplies configurations to a specific repository only.Provides a balance between security and functionality.
Handling Intermediate CertificatesEnsures the whole certificate chain is trusted by Git.Essential for multi-layered certificate structures.

Test these settings thoroughly in a secure environment before using them anywhere near production.


Course
Beginner
27 lessons
10 hours
System Design Fundamentals

Build a strong foundation in designing scalable, reliable distributed systems.

View the course
System Design practice on Codemia

Work through 120+ system design problems with detailed solutions, from rate limiters to multi-region storage.

Practice system design