Quick verdict: cURL's -k (or --insecure) skips SSL certificate verification entirely. Use it ONLY for local testing, self-signed certificates in dev environments, or one-off debugging. Never use it in production scripts — you lose the security guarantee that you are talking to the right server. The right fix for a "cert verification failed" error is almost always to use --cacert /path/to/ca-bundle.crt or to fix the cert chain.
# Long form
curl --insecure https://localhost:8443
# Short form
curl -k https://localhost:8443Both are identical. With this flag:
openssl req -newkey ... generated cert.api.example.com but you are checking 192.168.1.10.If your production script needs -k "just to make it work," you have a cert problem. Fix the cert.
Trust a specific cert without disabling all verification:
curl --cacert /path/to/server.crt https://localhost:8443cURL uses server.crt as the CA bundle for THIS request only. The rest of the system trust store is unchanged.
Add the corporate root CA to your system trust store:
# Linux (Debian/Ubuntu)
sudo cp corp-root-ca.crt /usr/local/share/ca-certificates/
sudo update-ca-certificates
# macOS
sudo security add-trusted-cert -d -r trustRoot -k /Library/Keychains/System.keychain corp-root-ca.crt
# Windows (cURL ships with its own bundle)
curl --cacert C:path ocorp-ca.crt https://internal.corp.localAfter this, normal curl works without flags.
If your cert is for api.example.com but you want to test against IP 10.0.0.5:
curl --resolve api.example.com:443:10.0.0.5 https://api.example.com/healthcURL sends a SNI for api.example.com, validates the cert against that hostname, but actually connects to 10.0.0.5. Keeps verification on.
Your system trust store does not have the CA that signed the server's cert. Fixes:
ca-certificates package: apt update && apt install --reinstall ca-certificates--cacert as aboveThe cert is valid but for a different hostname. Solutions:
--resolve hostname:port:ip as aboveRenew the cert. -k would mask this and let your script keep "working" on an expired cert — bad. Set up Let's Encrypt + certbot for auto-renewal.
When using a proxy with HTTPS, cURL needs to verify two cert chains: the proxy itself, and the target through the proxy. Separate flags:
# Skip target cert check only
curl --proxy http://gw.spyderproxy.com:8000 -k https://target.com
# Skip proxy cert check only (rare, HTTPS proxies)
curl --proxy https://proxy.example.com:8000 --proxy-insecure https://target.com
# Trust specific cert for the target
curl --proxy http://gw.spyderproxy.com:8000 --cacert target.crt https://target.comFor SpyderProxy and most commercial residential proxies, the proxy uses standard CA-signed certs — no flags needed. The flags above are only for self-signed proxy setups.
| Tool | Disable SSL verification |
|---|---|
| cURL | -k or --insecure |
| Python requests | verify=False |
| Python urllib | context=ssl._create_unverified_context() |
| aiohttp | connector=aiohttp.TCPConnector(ssl=False) |
| httpx | verify=False |
| Node.js fetch | NODE_TLS_REJECT_UNAUTHORIZED=0 env var |
| wget | --no-check-certificate |
| git | git config --global http.sslVerify false (bad idea) |
All have the same warning: convenient for dev, dangerous for prod.
Find every script in a codebase that uses -k:
grep -rn "curl.*-k|curl.*--insecure" .Each match deserves a comment explaining why, or a refactor to remove. CI security scanners (Snyk, Semgrep) flag this pattern as a code smell.
Related: cURL basic authentication, curl vs wget, Fix SSL certificate errors.