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:
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.
› 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:
or
Only that repository then trusts the certificate or skips verification.
Step 3: Test the configuration
Clone, fetch, or push against the repository:
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.
- Concatenate the certificates into a single file:
- Point
http.sslCAInfoat the combined file:
Comparing the options
| Method | Description | Security Considerations |
| Trust Globally | Sets a global configuration for Git to accept self-signed certificates. | Safe if the certificate is controlled and trusted. |
| Disable SSL Verification | Disables SSL verification entirely. | Risky, shouldn't be used in production scenarios. |
| Repository-Specific Configuration | Applies configurations to a specific repository only. | Provides a balance between security and functionality. |
| Handling Intermediate Certificates | Ensures 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.
Related reading
- How can I prevent SQL injection in PHP?
- How can I protect my .NET assemblies from decompilation?
- How can I resolve the error The security token included in the request is invalid when running aws iam upload-server-certificate?
- How can I retrieve Basic Authentication credentials from the header?
- How can I make git pull use rebase by default for all my repositories?
- How can I make git show a list of the files that are being tracked?
- How can I make the console.log at the bottom wait until its all complete, then show me the answer instead of waiting?
- How can I measure thread stack depth?

System Design Fundamentals
Build a strong foundation in designing scalable, reliable distributed systems.
View the courseSystem Design practice on Codemia
Work through 120+ system design problems with detailed solutions, from rate limiters to multi-region storage.