← All articles

Tutorials

cURL Ignore SSL: The -k Flag and When to Use It

Daniel K. · May 10, 2026 · 7 min read


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.

The Flag

# Long form
curl --insecure https://localhost:8443

# Short form
curl -k https://localhost:8443

Both are identical. With this flag:

When -k Is Acceptable

When -k Is Dangerous

If your production script needs -k "just to make it work," you have a cert problem. Fix the cert.

The Right Alternatives

1. Self-signed cert: --cacert

Trust a specific cert without disabling all verification:

curl --cacert /path/to/server.crt https://localhost:8443

cURL uses server.crt as the CA bundle for THIS request only. The rest of the system trust store is unchanged.

2. Corporate CA: --capath or system trust

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.local

After this, normal curl works without flags.

3. Hostname mismatch: --resolve

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/health

cURL sends a SNI for api.example.com, validates the cert against that hostname, but actually connects to 10.0.0.5. Keeps verification on.

Common SSL Errors That Tempt -k

SSL certificate problem: unable to get local issuer certificate

Your system trust store does not have the CA that signed the server's cert. Fixes:

SSL: no alternative certificate subject name matches target host name

The cert is valid but for a different hostname. Solutions:

SSL certificate has expired

Renew 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.

SSL Verification With Proxies

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.com

For 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.

Equivalents in Other Tools

ToolDisable SSL verification
cURL-k or --insecure
Python requestsverify=False
Python urllibcontext=ssl._create_unverified_context()
aiohttpconnector=aiohttp.TCPConnector(ssl=False)
httpxverify=False
Node.js fetchNODE_TLS_REJECT_UNAUTHORIZED=0 env var
wget--no-check-certificate
gitgit config --global http.sslVerify false (bad idea)

All have the same warning: convenient for dev, dangerous for prod.

Auditing -k Usage

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.

Scraping at scale without getting blocked?

See residential proxies ↗Start now ↗