# curl Ignore SSL Certificate: -k and --cacert

> Make curl ignore SSL certificate errors with -k or --insecure: the real error lines and exit codes, certificates through a proxy, and --cacert to trust one.

[Home](https://quanticdata.io/) / [Blog](https://quanticdata.io/blog/) / curl Ignore SSL Certificate: -k and --cacert

# How to make curl ignore SSL certificate errors, and the safer fix

Proxies · Nov 20, 2026 · 7 min read · By [Aldo Morese](https://quanticdata.io/about/), founder of QuanticData

![How curl handles a bad TLS certificate: without -k the request stops with exit code 60 for a self-signed or untrusted certificate and 35 for an expired one; with -k or --insecure it returns 200; the safer path, --cacert with the server certificate, also returns 200 while keeping the check on.](https://quanticdata.io/blog/curl-ignore-ssl-certificate/hero.webp?v=20261120h)

On this page

- [The four certificate errors and what -k does to each](https://quanticdata.io/blog/curl-ignore-ssl-certificate/#the-four-certificate-errors-and-what-k-does-to-each)
- [The command, short and long form](https://quanticdata.io/blog/curl-ignore-ssl-certificate/#the-command-short-and-long-form)
- [The safer fix: trust one certificate with --cacert](https://quanticdata.io/blog/curl-ignore-ssl-certificate/#the-safer-fix-trust-one-certificate-with-cacert)
- [Certificates through a proxy: no -k needed](https://quanticdata.io/blog/curl-ignore-ssl-certificate/#certificates-through-a-proxy-no-k-needed)
- [Check the result in a script](https://quanticdata.io/blog/curl-ignore-ssl-certificate/#check-the-result-in-a-script)
- [Turning it on for every command, and why not to](https://quanticdata.io/blog/curl-ignore-ssl-certificate/#turning-it-on-for-every-command-and-why-not-to)
- [Windows: curl.exe, the PowerShell alias and two TLS libraries](https://quanticdata.io/blog/curl-ignore-ssl-certificate/#windows-curl-exe-the-powershell-alias-and-two-tls-libraries)
- [When -k is fine and when it is not](https://quanticdata.io/blog/curl-ignore-ssl-certificate/#when-k-is-fine-and-when-it-is-not)

To make curl ignore SSL certificate errors, add `-k` (long form `--insecure`): `curl -k https://example.com/`. curl then accepts an expired, self-signed or wrong-host certificate. The safer fix is `--cacert file.pem`, which trusts that one certificate and keeps the check for everything else.

**Run it on the free credit.** Every QuanticData account gets $2 of free API usage per month.

[Start free — $2/month included](https://quanticdata.io/signup/?utm_source=blog&utm_medium=website&utm_campaign=blog-lead&utm_content=curl-ignore-ssl-certificate) · [Explore Residential Proxies from $0.80/GB](https://quanticdata.io/residential-proxies/)

We triggered each certificate error on purpose on 20 November 2026, with the curl.exe that ships with Windows 11 (curl 8.22.0, Schannel), against the test hosts of badssl.com, then repeated the commands through QuanticData residential and mobile proxies. Every line of output below is from those runs.

## The four certificate errors and what -k does to each

Without `-k`, curl stops before it sends the request and prints why. With `-k`, the same URL answers 200.

| Test host | What is wrong | curl without -k | Exit code | With -k |
| --- | --- | --- | --- | --- |
| expired.badssl.com | Certificate past its end date | SEC_E_CERT_EXPIRED, "The received certificate has expired." | 35 | 200 |
| self-signed.badssl.com | Signed by itself | SEC_E_UNTRUSTED_ROOT | 60 | 200 |
| untrusted-root.badssl.com | Chain ends in an unknown authority | SEC_E_UNTRUSTED_ROOT | 60 | 200 |
| wrong.host.badssl.com | Certificate made for another name | SEC_E_WRONG_PRINCIPAL, "The target principal name is incorrect." | 60 | 200 |

```bash
$ curl -sS -o /dev/null -w "%{http_code}\n" https://self-signed.badssl.com/
curl: (60) schannel: SEC_E_UNTRUSTED_ROOT (0x80090325) - The certificate chain was issued by an authority that is not trusted.
More details here: https://curl.se/docs/sslcerts.html

curl failed to verify the legitimacy of the server and therefore could not
establish a secure connection to it. To learn more about this situation and
how to fix it, please visit the webpage mentioned above.
000

$ curl -sS -k -o /dev/null -w "%{http_code}\n" https://self-signed.badssl.com/
200
```

Two exit codes cover these cases on Windows: 60 when curl cannot trust the certificate or its name, 35 when the handshake itself fails, which is how the Windows TLS library reports an expired certificate. Scripts should test the exit code, not grep the message: the text comes from the TLS library curl was built with.

## The command, short and long form

- **`-k`** and **`--insecure`** are the same option. Put it anywhere on the line.
- **It only skips the certificate check.** curl still speaks HTTPS to the server; what it drops is the proof of who the server is.
- **It does not change anything else**: headers, method and output options work as before, so `-k -s -o /dev/null -w "%{http_code}"` prints just the status, as in the commands above.

```bash
curl -k https://self-signed.badssl.com/
curl --insecure https://expired.badssl.com/
```

## The safer fix: trust one certificate with --cacert

When the server is yours (a test box, a router, an internal tool with a self-signed certificate), give curl that certificate instead of switching the check off. curl then accepts that server and still rejects every other bad certificate. We saved the self-signed certificate with openssl, then pointed curl at it:

```
echo | openssl s_client -connect self-signed.badssl.com:443 -servername self-signed.badssl.com 2>/dev/null | openssl x509 > self.pem
curl --cacert self.pem -o /dev/null -w "%{http_code}\n" https://self-signed.badssl.com/
200
```

The same `--cacert self.pem` worked with the second curl on our PC, the one bundled with Git for Windows (curl 8.21.0), which on its own also stopped with exit 60. For a company's internal authority, point `--cacert` at the authority's certificate rather than at each server's.

## Certificates through a proxy: no -k needed

A forward proxy does not change the certificate question. For an https:// URL, curl asks the proxy for a tunnel (CONNECT) and does TLS with the site through it, so the certificate curl checks is the site's own. We sent a plain HTTPS request, with the check on and no `-k`, through each of three QuanticData networks:

```bash
curl -sS -x http://residentialboson.quanticdata.io:10000 -U "USER-type-residential-country-us-session-fx01-lifetime-30:PASS" -o /dev/null -w "%{http_code} verify=%{ssl_verify_result}\n" https://ipinfo.io/ip
curl -sS -x http://residentialpremium.quanticdata.io:8080 -U "USER-country-de-sid-fx02-ttl-30m:PASS" -o /dev/null -w "%{http_code} verify=%{ssl_verify_result}\n" https://ipinfo.io/ip
curl -sS -x http://mobile.quanticdata.io:8080 -U "USER-country-us-type-mobile-sid-fx03-ttl-30m:PASS" -o /dev/null -w "%{http_code} verify=%{ssl_verify_result}\n" https://ipinfo.io/ip
```

| Network | ipinfo.io, valid certificate, no -k | self-signed.badssl.com, no -k |
| --- | --- | --- |
| Residential Basic, US | 200, verify=0 | exit 60, the same SEC_E_UNTRUSTED_ROOT line as without a proxy |
| Residential Premium, Germany | 200, verify=0 | exit 60, the same line |
| Mobile, US | 200, verify=0 | exit 60, the same line |

Two things follow. The valid site passed the check through all three networks, so you do not need `-k` for these requests and should not add it "just in case". And each network showed the bad certificate exactly as a direct connection did: curl checked the site's own certificate. If a certificate error ever appears only behind some other proxy, that proxy is inspecting the traffic; that case has its own guide, [CERTIFICATE_VERIFY_FAILED behind a proxy](https://quanticdata.io/blog/ssl-certificate-verify-failed-proxy/). Gateways, usernames and SOCKS5 are covered in [how to use a proxy with curl](https://quanticdata.io/blog/how-to-use-a-proxy-with-curl/).

**Try it on your own targets.** Every QuanticData account gets $2 of free API usage per month.

[Start free — $2/month included](https://quanticdata.io/signup/?utm_source=blog&utm_medium=website&utm_campaign=blog-inline&utm_content=curl-ignore-ssl-certificate) · [Explore Residential Proxies from $0.80/GB](https://quanticdata.io/residential-proxies/)

## Check the result in a script

When curl runs inside a script or a scheduled job, nobody reads the error line. Two things tell the script what happened: the exit code, and the write-out variable `%{ssl_verify_result}`, which is 0 when the certificate check passed.

```bash
curl -sS -x http://residentialboson.quanticdata.io:10000 -U "USER-...:PASS" -o /dev/null \
  -w "%{http_code} verify=%{ssl_verify_result}\n" https://ipinfo.io/ip
200 verify=0

curl -sS -o /dev/null -w "%{http_code}\n" https://self-signed.badssl.com/; echo "exit=$?"
curl: (60) schannel: SEC_E_UNTRUSTED_ROOT (0x80090325) - The certificate chain was issued by an authority that is not trusted.
000
exit=60
```

Note the `000`: when the check fails, no HTTP response exists, so a script that only reads the status code sees 000, not an error page.

A job that treats exit 60 and 35 as "certificate problem, stop and alert" and every other non-zero code as "network problem, retry" keeps the check useful instead of hiding it behind `-k`.

## Turning it on for every command, and why not to

curl reads options from a config file: `insecure` on a line of its own works like `-k`. We tested it with `-K`, which loads a given file:

```bash
$ cat curlrc-test
insecure
$ curl -K curlrc-test -o /dev/null -w "%{http_code}\n" https://self-signed.badssl.com/
200
```

Written into curl's default config file, the same line would apply to every command you run, including the ones that log in, download installers or call payment APIs. Keep `insecure` out of it; use `-k` on the one command that needs it, or `--cacert`.

## Windows: curl.exe, the PowerShell alias and two TLS libraries

- **In Windows PowerShell, type `curl.exe`.** `curl` alone is an alias of Invoke-WebRequest there and has no `-k`. The guide to [proxies in PowerShell](https://quanticdata.io/blog/powershell-proxy-setup/) shows the alias error.
- **The Windows curl uses Schannel**, the Windows TLS library, so its messages read `SEC_E_...` and carry a Windows error number, as in the table above.
- **A second curl may be on your PATH.** Ours had curl 8.21.0 from Git for Windows next to the system one; `curl --version` shows which one runs.

## When -k is fine and when it is not

| Situation | Use |
| --- | --- |
| Your own test server or a device with a self-signed certificate | `--cacert` with its certificate; `-k` for a one-off check |
| A public site with an expired certificate you only read | `-k` on that command |
| Anything with a password, a token, a payment or a download you will run | Never `-k`: fix the certificate or the trust store |
| Scraping public pages through a proxy | No `-k`: our valid test site passed the check through all three of our networks |

For collection jobs that need a home or carrier IP, our [residential proxies](https://quanticdata.io/residential-proxies/) and [mobile proxies](https://quanticdata.io/mobile-proxies/) take the same `-x` and `-U` options shown above; there is a [Residential Basic free trial](https://quanticdata.io/residential-proxy-free-trial/) to try them. Our [MCP server](https://quanticdata.io/mcp-server/) can generate the proxy lines for you.

### Sources & further reading

- [curl manual: -k, --insecure](https://curl.se/docs/manpage.html#-k)
- [curl manual: --cacert](https://curl.se/docs/manpage.html#--cacert)
- [curl: SSL certificate verification](https://curl.se/docs/sslcerts.html)
- [badssl.com test hosts](https://badssl.com/)

## FAQ

Quick answers on curl ignore ssl certificate.

[Something else? Ask us](mailto:hello@quanticdata.io)

### How do I make curl ignore SSL certificate errors?

Add `-k` or `--insecure`: `curl -k https://example.com/`. In our test it turned exit 60 (self-signed, untrusted root, wrong host) and exit 35 (expired) into a 200 response.

### Is curl -k the same as --insecure?

Yes. `-k` is the short form of `--insecure`; both skip the check of the server certificate and change nothing else in the request.

### What does curl error 60 mean?

curl could not verify the certificate: it is self-signed, signed by an authority your system does not trust, or made for another host name. On Windows the message reads `SEC_E_UNTRUSTED_ROOT` or `SEC_E_WRONG_PRINCIPAL`. Fix it with `--cacert` and the right certificate, or skip the check with `-k` on that one command.

### How do I trust a self-signed certificate in curl without -k?

Save the certificate as PEM and pass it with `--cacert`: `curl --cacert self.pem https://host/`. We saved it with `openssl s_client` piped to `openssl x509`, and curl answered 200 with the check still on.

### Do I need -k when curl goes through a proxy?

Not for a site with a valid certificate. curl opens a tunnel and checks the site certificate itself; a valid site answered 200 with the check passed through Residential Basic, Residential Premium and Mobile, without `-k`. You need `-k` only for the same bad certificates that fail without a proxy.

### How do I ignore SSL errors with curl on Windows?

Run `curl.exe -k URL`. In Windows PowerShell type `curl.exe`, because `curl` alone is an alias of Invoke-WebRequest and does not know `-k`.

## Proxies that keep your TLS checks on

Residential and mobile proxies that tunnel HTTPS end to end, ready for curl -x with country targeting and sticky sessions.

[Start free — $2/month included](https://quanticdata.io/signup/?utm_source=blog&utm_medium=website&utm_campaign=blog-end&utm_content=curl-ignore-ssl-certificate) · [Explore Residential Proxies from $0.80/GB](https://quanticdata.io/residential-proxies/)

## Related reading

- [curl Basic Auth: -u, Header, .netrc, Proxy](https://quanticdata.io/blog/curl-basic-auth/): Proxies · curl -u user:password sends HTTP basic authentication: curl base64-encodes the pair into an Authorization header. Below: the header we captured with -v, the same header built by hand, passwords with colons and @, the prompt, .netrc, digest, and why a proxy login goes in -U, not -u.
- [curl Download File: -O, -o, -L and Resume](https://quanticdata.io/blog/curl-download-file/): Proxies · curl -O URL saves the file under its remote name, curl -o name URL under the name you choose, and -L follows redirects such as GitHub's. Below: every option run for real, including the 0-byte file a 302 leaves behind, a resumed download that matched the original byte for byte, and 1 MB through residential and mobile proxies.
- [curl Show Response Headers and Send Headers](https://quanticdata.io/blog/curl-headers/): Proxies · curl -i prints the response headers with the body, -I only the headers (with a HEAD request), and -D - -o /dev/null the headers of a normal GET. To send headers, use -H "Name: value", once per header. Below: all of it run for real, plus a single header with -w, removing curl's defaults, headers from a file, and what a proxy sees.

---

Source: https://quanticdata.io/blog/curl-ignore-ssl-certificate/ · Site index for AI: https://quanticdata.io/llms.txt
