How to Ignore SSL Certificate in cURL and When It’s Safe To

An image of a padlock, a check mark, a warning sign, and a window with the text

Share

IN THIS ARTICLE:

If you ever worked with APIs or tested HTTPS endpoints using curl, you’ve probably run into a frustrating SSL error — especially when dealing with self-signed certificates or local environments. To quickly get past it, many developers use the -k or —insecure flag to “ignore SSL”. But what exactly does this do? And is it safe?

In this article, we’ll explore how curl handles SSL verification, what happens when you bypass it using -k, and — most importantly — when doing so is acceptable or poses a serious security risk. Whether you’re debugging a local server or building automation scripts, understanding this tiny flag can save you time and possibly protect you from a security breach.

A drawin gof a page with a padlock on it, a warning symbol, and a depiction of the internet under the title

What is SSL Verification in cURL?

When you make an HTTPS request using curl, it doesn’t just connect to the server it also verifies that the server’s SSL/TLS certificate is valid and trustworthy. This process is called SSL certificate verification, and it’s an important security feature built into curl by default.

Why it matters:

SSL (Secure Sockets Layer), or more accurately TLS (Transport Layer Security), is what keeps your data encrypted when sent over the internet. Before curl sends any data to the server, it checks:

  • Is the certificate issued by a trusted Certificate Authority (CA)?
  • Is the certificate expired or still valid?
  • Does the certificate match the domain name you’re connecting to?

If any of these checks fail, curl will stop the request and return an error like:

curl: (60) SSL certificate problem: self signed certificate

This behavior is intentional and protective; it prevents you from accidentally sending sensitive data to a potentially malicious or misconfigured server.

curl https://example.com
# If the SSL cert is invalid or untrusted, you'll see an error.

So when you see an SSL error in curl, it’s not a bug; it’s a warning that something might be wrong with the server’s security setup.

A drawing of a browser with a -k, a padlock with a broken chain, and a warning sign, under the title

How to Ignore SSL in cURL

If you’re working with a local server, a staging environment, or an internal tool using a self-signed or misconfigured certificate, curl will throw an SSL error by default. In such cases when you’re sure the connection is safe you can bypass SSL certificate verification using the -k or --insecure flag and you have two options: the basic and the long version syntax.

Basic syntax:

curl -k https://your-url.com

Long version:

curl --insecure https://your-url.com

This tells curl to skip the SSL certificate checks entirely. The request will go through, even if the certificate is invalid, expired, or self-signed.

However, using -k makes your connection vulnerable to man-in-the-middle (MITM) attacks because you’re disabling the very mechanism that ensures you’re talking to the correct server. That’s why this flag should only be used in specific scenarios, namely:

  • In trusted environments (like your local machine)
  • For debugging or testing purposes
  • With full awareness of the security implications

Never use -k in production scripts, on public networks, or with sensitive data.

A drawing of a house, flasks, a shield, and a magnifying glass under the title

When is it Okay to Ignore SSL?

While skipping SSL verification with curl -k is generally discouraged, there are a few limited, controlled scenarios where it’s acceptable, even practical to use it. The key is understanding the context and risks. Safe use cases include:

Local Development

  • You’re working on localhost with a self-signed certificate.
  • The SSL cert isn’t from a trusted Certificate Authority (CA), but you trust it because you generated it yourself.

Testing/Staging Environments

  • Temporary systems where security isn’t the top priority (yet).
  • For example, automated tests or internal QA setups using mock data.

Internal or Isolated Networks

  • Servers are behind a firewall or VPN, and both client and server are under your full control.
  • No public internet exposure, and risk of interception is extremely low.

Short-Term Debugging

  • You’re quickly diagnosing an issue with an endpoint and want to isolate the problem without worrying about SSL errors.
  • As long as you remember to remove the flag later

Still, be cautious. Even in these “safe” situations, it’s better practice to:

  • Use tools like mkcert to generate trusted certs for local dev.
  • Add your self-signed cert to your system’s trust store.
  • Fix the SSL issue instead of working around it permanently.

Using curl -k should always be a temporary workaround, not a long-term solution.

A drawing of a document with a warning sign, a broken padlock, and a menacing figure under the title

Why Ignoring SSL in Production Is Dangerous

Using the -k or --insecure flag in production environments might seem like a quick fix, but it’s one of the riskiest shortcuts you can take. SSL/TLS is what protects data in transit, verifies the identity of servers, and prevents third parties from intercepting or altering your data. Disabling it effectively removes all of that protection.

Here’s why it’s a bad idea in production:

  1. You’re Open to MITM Attacks: When SSL verification is off, attackers on the same network can intercept and alter your data before it reaches its destination or impersonate the server entirely. This is especially dangerous on public Wi-Fi or cloud infrastructure.
  2. Sensitive Data Can Be Exposed: Login credentials, API keys, customer information, anything sent over that insecure connection can be intercepted. This can lead to data leaks, identity theft, or account compromise.
  3. You Break the Trust Model of HTTPS: SSL certificates prove that you’re talking to the real server, not a fake or hijacked one. Ignoring SSL verification throws away this guarantee and opens the door to spoofed services.
  4. It Violates Compliance Standards: If you’re working in industries like finance, healthcare, or e-commerce, bypassing SSL could violate regulations like GDPR, HIPAA, PCI-DSS, or SOC 2.
  5. You May Not Notice a Real Security Issue: Sometimes SSL errors are warning you about an expired, revoked, or misconfigured certificate. Ignoring these errors blindly may cause you to miss serious underlying issues that need fixing.

Alternatives to Ignoring SSL with cURL

Instead of using curl -k to bypass SSL verification, there are safer and more reliable ways to deal with SSL-related issues especially if you’re in development or testing environments. Here are a few secure alternatives:

1. Use a Trusted Certificate

The most straightforward fix is to install a valid SSL certificate issued by a trusted Certificate Authority (CA). You can get one for free using:

This ensures your certificate will pass cURL’s default verification.

2. Use mkcert for Local Development

If you’re working locally and don’t want to mess with full CA signing, mkcert is a great tool. It creates locally-trusted development certificates without requiring the -k flag.

mkcert localhost

Then, configure your server to use the generated certificate, and cURL won’t complain.

3. Add the Certificate to Your Trusted Store

If you’re using a self-signed certificate, you can explicitly trust it by adding it to your system’s certificate store or passing it to curl using –cacert.

curl --cacert /path/to/certificate.pem https://your.server.com

This lets cURL verify SSL without disabling it entirely.

4. Fix the Root Issue

Often, SSL issues are due to misconfiguration: expired certs, wrong domain names, or missing intermediate certs. It’s better to:

  • Regenerate the certificate properly
  • Check the certificate chain
  • Ensure the server is serving the full certificate bundle

5. Use Environment-Based Logic (Advanced)

If you’re writing scripts or apps, consider toggling SSL verification based on environment variables:

if ["$ENV" = "production"]; then
crul https://api.yourdomain.com
else
curl -k https://dev.api.yourdomain.com
fi

Keep in mind that even in dev, it’s better to fix SSL instead of ignoring it.

A drawing of a check mark and people behind it, a document with check marks, a browser window, and other icons under the title

Best Practices When Ignoring SSL with cURL

Ignoring SSL with curl -k might be tempting when you’re in a rush, but long-term, it’s better to build habits that prioritize security and reliability. Here are some best practices to follow when working with cURL and SSL:

Avoid -k in Scripts and Automation

Hardcoding -k in shell scripts, CI pipelines, or production systems creates silent vulnerabilities that can be forgotten over time. Always verify certificates unless there’s a very specific, documented reason not to.

Fix the Certificate, Not the Client

If SSL verification fails, try to solve the root cause:

  • Use a valid certificate.
  • Check that the hostname matches.
  • Ensure the full certificate chain is provided by the server.

Don’t mask the problem with --insecure.

Use Environment-Specific Certificates

Use tools like mkcert for local development and trusted CA-issued certificates for production. This keeps dev environments flexible without compromising prod security.

Use –cacert or –cert Instead of -k

If you’re working with internal or self-signed certs, provide cURL with a trusted cert directly:

curl --cacert /path/to/ca.pem https://your-server.com

This maintains security while allowing for non-public certs.

Document and Review Exceptions

If you ever need to disable SSL verification (even temporarily), document why, where, and when  and include a reminder to fix it. Regularly review your code and scripts for insecure flags like -k.

Educate Your Team

Sometimes shortcuts are copied without understanding the risks. Make sure your team knows:

  • What -k does
  • When it’s appropriate (rarely)
  • Safer alternatives they can use

Conclusion

The curl -k or --insecure flag can be a helpful tool when you’re developing locally or working with trusted, internal systems, but it’s not a free pass to ignore security. SSL verification exists to protect your data, confirm the identity of servers, and prevent MITM attacks. Disabling it without understanding the risks can open serious vulnerabilities, especially in production environments.

Key Takeaways:

  • curl -k disables SSL verification — use it only in safe, local environments.
  • Ignoring SSL in production can lead to data leaks, MITM attacks, and compliance violations.
  • Safer alternatives include using trusted certs, mkcert, or the --cacert flag.
  • Avoid hardcoding -k in scripts or CI/CD pipelines — it creates long-term risks.
  • Fix the underlying SSL issue whenever possible instead of working around it.

Whenever possible, fix the SSL issue instead of bypassing it. Use proper certificates, trust your internal certs securely, and rely on tools like mkcert to avoid the need for insecure flags altogether.

About the author

Yazan is a Software Engineer at Proxidize with a passion for technology and a love for building things with code. He has worked in several industries, including consulting and healthcare, and is currently focused on proxy technologies.
IN THIS ARTICLE:

Save Up To 90% on Your Proxies

Discover the world’s first distributed proxy network, which guarantees the best IP quality, reliability and price.

Related articles

Similarities Between Virtual Machines and Antidetect Browsers

Virtual machines and antidetect browsers are very different technologies that are generally used for different tasks. However, they share similarities

Zeid Abughazaleh

Proxidize & Kameleo: Streamlining Anti-Detect Browsing Success
Proxidize & Kameleo: Seamless Anonymity

Understanding Browser Fingerprinting Ever wondered how websites get to know so much about your web browser? It’s through a technique

Abed Elezz

3 Ways to Scrape PDF in Python

There are three main ways to scrape PDF files. You could either write a script that will scrape PDF from

Zeid Abughazaleh

Using cURL with Python

If you have experience with Python or have been reading documentation related to the programming language, you may have come

Zeid Abughazaleh

Start for Free! Start for Free! Start for Free! Start for Free! Start for Free! 

Talk to Our Sales Team​

Looking to get started with Proxidize? Our team is here to help.

“Proxidize has been instrumental in helping our business grow faster than ever over the last 12 months. In short, Proxidize has empowered us to have control over every part of our business, which should be the goal of any successful company.”

mobile-1.jpg
Makai Macdonald
Social Media Lead Specialist | Product London Design UK

What to Expect:

By submitting this form, you consent to receive marketing communications from Proxidize regarding our products, services, and events. Your information will be processed in accordance with our Privacy Policy. You may unsubscribe at any time.

Contact us
Contact Sales