SSL certificate problem: unable to get local issuer certificate error (या इसके variants) सबसे common development problems में से एक है। इसका मतलब है कि tool server की certificate chain को verify नहीं कर सकता — usually इसलिए क्योंकि आपके system पर CA root certificates पुराने हैं या missing हैं।
यह guide proper solutions बताती है — सिर्फ -k / --insecure workarounds नहीं जो security disable करते हैं।
Root Cause
आपके tools SSL certificates को एक CA bundle — trusted root certificates वाली file — के against verify करते हैं। जब यह bundle outdated, missing, या server की chain incomplete होती है, तो verification fail हो जाता है।
Your tool → "Is this certificate signed by a CA I trust?"
CA bundle → "I don't have that CA's root certificate"
→ ERROR: unable to get local issuer certificate
curl
Error
curl: (60) SSL certificate problem: unable to get local issuer certificate
Solution 1: CA Certificates Update करें (सही solution)
# Debian/Ubuntu
sudo apt update && sudo apt install ca-certificates
sudo update-ca-certificates
# CentOS/RHEL
sudo yum update ca-certificates
# macOS (Homebrew curl)
brew install ca-certificates
Solution 2: CA Bundle Path Specify करें
curl --cacert /etc/ssl/certs/ca-certificates.crt https://example.com
Solution 3: Environment Variable Set करें
export CURL_CA_BUNDLE=/etc/ssl/certs/ca-certificates.crt
ऐसा न करें (जब तक testing न हो)
curl -k https://example.com # सभी certificate verification disable करता है
Git
Error
fatal: unable to access 'https://...': SSL certificate problem: unable to get local issuer certificate
Solution 1: CA Certificates Update करें (curl जैसा ही)
sudo apt update && sudo apt install ca-certificates
Solution 2: Git को सही CA Bundle पर Point करें
git config --global http.sslCAInfo /etc/ssl/certs/ca-certificates.crt
Solution 3: Windows पर (Git for Windows)
Git for Windows अपने खुद के CA certs bundle करता है। Git को latest version में update करें, या:
git config --global http.sslBackend schannel
यह Git को अपने bundled CA certs के बजाय Windows के built-in certificate store use करने के लिए कहता है।
Production में ऐसा न करें
git config --global http.sslVerify false # Git के लिए सभी SSL verification disable करता है
Python (requests / pip)
Error (requests)
requests.exceptions.SSLError: [SSL: CERTIFICATE_VERIFY_FAILED]
Error (pip)
pip install ... Could not fetch URL https://...: connection error: [SSL: CERTIFICATE_VERIFY_FAILED]
Solution 1: certifi Update करें (Python का CA bundle)
pip install --upgrade certifi
Python की requests library CA certificates के लिए certifi package use करती है, system store का नहीं।
Solution 2: System CA Bundle पर Point करें
import requests
response = requests.get('https://example.com', verify='/etc/ssl/certs/ca-certificates.crt')
या environment variable:
export REQUESTS_CA_BUNDLE=/etc/ssl/certs/ca-certificates.crt
Solution 3: macOS Python (common problem)
macOS Python में install के बाद अक्सर एक empty certificate store होता है। Run करें:
# अपना Python install find करें
python3 -c "import ssl; print(ssl.get_default_verify_paths())"
# Certificates install करें (python.org से macOS Python)
/Applications/Python\ 3.x/Install\ Certificates.command
pip के लिए Special Solution
pip install --upgrade pip
pip config set global.cert /etc/ssl/certs/ca-certificates.crt
Node.js
Error
Error: unable to get local issuer certificate
code: 'UNABLE_TO_GET_ISSUER_CERT_LOCALLY'
Solution 1: NODE_EXTRA_CA_CERTS Set करें
export NODE_EXTRA_CA_CERTS=/etc/ssl/certs/ca-certificates.crt
यह Node के built-in bundle को replace किए बिना additional CAs add करता है।
Solution 2: Development में Self-signed Certs के लिए
// Only for development — adds a specific CA
const https = require('https');
const fs = require('fs');
const agent = new https.Agent({
ca: fs.readFileSync('/path/to/custom-ca.pem'),
});
fetch('https://internal-service.local', { agent });
Production में ऐसा न करें
export NODE_TLS_REJECT_UNAUTHORIZED=0 # सभी SSL verification disable करता है
Corporate Proxy / Enterprise Environments
कई corporate networks TLS inspection proxy use करते हैं जो traffic को internal CA के साथ re-sign करता है। आपके tools इस internal CA पर trust नहीं करते।
Fix: अपने IT department से corporate CA certificate get करें और इसे add करें:
# System-wide (Debian/Ubuntu)
sudo cp corporate-ca.crt /usr/local/share/ca-certificates/
sudo update-ca-certificates
# Python
export REQUESTS_CA_BUNDLE=/path/to/corporate-ca-bundle.pem
# Node.js
export NODE_EXTRA_CA_CERTS=/path/to/corporate-ca.pem
# Git
git config --global http.sslCAInfo /path/to/corporate-ca-bundle.pem
Docker Containers
Docker images में अक्सर outdated CA bundles होते हैं। Fix:
# Debian-based
RUN apt-get update && apt-get install -y ca-certificates && update-ca-certificates
# Alpine
RUN apk add --no-cache ca-certificates
Quick Diagnosis
# Test if the SSL connection works with openssl
openssl s_client -connect example.com:443 -servername example.com < /dev/null 2>/dev/null | grep "Verify return code"
# "0 (ok)" = chain is fine, your tool's CA bundle is the problem
# "21 (unable to verify)" = server's chain is incomplete
# Check what CA bundle your system uses
python3 -c "import certifi; print(certifi.where())"
curl-config --ca 2>/dev/null || echo "Check /etc/ssl/certs/"
FAQ
यह मेरे browser में काम करता है लेकिन curl/Python में क्यों नहीं?
Browsers अपना खुद का CA store maintain करते हैं (browser के साथ update होता है)। CLI tools system के CA bundle या अपने खुद के (Python certifi use करता है, Git for Windows अपना खुद का bundle करता है) use करते हैं। अगर system bundle outdated है, तो CLI tools fail हो जाते हैं जबकि browsers ठीक काम करते हैं।
क्या SSL verification disable करना safe है?
Quick testing के लिए: हां, अगर आप समझते हैं कि आप server की identity verify नहीं कर रहे हैं। Production code या CI/CD के लिए: कभी नहीं। Verification disable करना आपको man-in-the-middle attacks के लिए open छोड़ देता है। हमेशा root cause fix करें (CA bundle update करें या server की chain fix करें)।
Server का certificate ठीक है लेकिन मुझे अभी भी errors मिल रही हैं
Check करें कि क्या आपका tool किसी proxy से गुज़र रहा है जो traffic को re-sign करता है। Corporate networks, कुछ VPNs, और antivirus software ऐसा करते हैं। Proxy का CA आपके tool के trust store में नहीं है।