In This Article

Back to blog

How to Safely Use cURL to Ignore SSL Errors: A Complete Guide

Tutorials

Eugenijus Denisov

Last updated - ‐ 8 min read

Key Takeaways

  • SSL/TLS certificates primarily verify a server's identity (authentication), meaning that bypassing checks allows you to send encrypted data to a potentially unverified recipient.

  • While the -k or --insecure flags are useful for bypassing errors in local or staging environments, they should only be used when no sensitive credentials are being transmitted.

  • For live systems, you should avoid disabling security and instead use the --cacert flag to point cURL to a trusted CA bundle or specific self-signed file.

SSL/TLS (Secure Sockets Layer/Transport Layer Security) certificates are a way for client applications and browsers to verify the authenticity of a website. An invalid SSL certificate will almost always result in an error message, warning the user not to proceed further (although some browsers may provide a means to do so).

Additionally, when SSL certificate errors happen, it means the browser cannot verify who is on the receiving end of the data. Even though the connection itself may still be encrypted, you risk sending sensitive information to an imposter or a malicious third party.

While they usually shouldn’t be ignored, there’s sometimes a good reason to bypass SSL certificate validation. For example, a website may be known and trusted, but it simply had the certificate expire.

Understanding cURL and SSL

Most people will be familiar with the concept of an SSL certificate through a common error message that pops up when connecting to a website through a browser. SSL certificate errors, however, can happen through many different connection methods that work through HTTPS.

HTTPS relies on TLS (Transport Layer Security), the modern successor to SSL, to encrypt data and verify website identity. When a client, such as a browser or cURL, cannot authenticate a server’s certificate, it throws an error to warn the user and protect their data.

You can also be faced with SSL errors when using cURL . It’s a command-line tool that can work over numerous network protocols. Whenever you send a request through the HTTPS network protocol, cURL automatically attempts to validate the SSL certificate of a website.

When cURL can’t establish a secure connection due to SSL certificate errors, you’ll usually get an error message resembling the one below:

curl: (60) SSL certificate problem: unable to get local issuer certificate

Because verifying the server's identity is a strict security requirement of HTTPS, cURL defaults to terminating the connection when validation fails to prevent you from sending data to an unverified server. Sometimes, however, you may want to start ignoring SSL certificate checks when using cURL for advanced use cases .

Reasons to Disable SSL Verification

While less tech-savvy users shouldn’t disable SSL verification, developers may temporarily bypass it in specific, controlled scenarios. Keep in mind that doing so is never entirely without risk.

Even if you trust the website, ignoring SSL certificates leaves you vulnerable to man-in-the-middle attacks if you’re transmitting sensitive data or authentication tokens. Such an action won’t even need to be done for long, as most well-known websites will quickly fix the SSL certificate issue.

Another common reason to disable Secure Sockets Layer certificate verification is during local development or staging. Developers frequently use self-signed certificates for testing before pushing a site to production, which cURL will inherently flag as invalid unless told to ignore them.

Finally, you might bypass SSL checks when debugging other functionality on a website while its security certificate is temporarily broken or still being set up.

Note: If you’re debugging the SSL connection itself, you actually want cURL to show you the errors so you can see exactly where the handshake is failing.

Ready to get started?
Register now

How Do I Ignore SSL Certificate Errors in cURL?

You can use cURL to ignore SSL with a single command. There’s a specific cURL flag you need to set: -k or --insecure. Using this cURL flag specifically tells the tool to bypass the server’s SSL certificate validation step during the HTTPS handshake:

curl -k https://httpbin.org

Note that the HTTPS prefix is important as there’s no SSL certificate verification otherwise. In such a case, the flag would be redundant.

As with any other command, the cURL ignore SSL flag can be combined with almost any other. You can send, for example, a POST request while using the cURL ignore SSL errors flag at the same time:

curl -k -X POST -H "Content-Type: application/json" -d '{"key":"value"}' https://jsonplaceholder.typicode.com/users

There are plenty of other things you can do while the flag is set, such as send GET requests , use cURL proxies , and much more.

These flags, however, should be used sparingly. Even though the connection remains encrypted, skipping SSL certificate validation means you cannot mathematically guarantee you’re communicating with the intended server.

How to Bypass SSL Without Disabling Security Checks?

Most such strategies revolve around manually implementing certificates to ignore SSL certificate checks. None of these are great if you’re connecting to a website you don’t own or manage, but they can come in handy when you’re testing or debugging.

First, you can add a self-signed SSL certificate to your operating system's local CA store. Alternatively, you can bypass system-wide settings entirely by using cURL's --cacert <file> flag, which allows you to point directly to your specific self-signed certificate file to validate the connection.

On the other hand, you can use an SSL proxy to terminate any SSL certificate verification. Instead of having the client communicate directly with the server, the proxy manages the client’s and server's responses.

While the proxy handles the external SSL connection, it must re-encrypt the traffic before sending it to your local machine. Because the proxy signs this traffic with its own local SSL certificate, you’ll still need to configure cURL to trust the proxy's root certificate to avoid SSL certificate problems.

Finally, there’s certificate pinning. Rather than bypassing the SSL process, pinning makes it stricter by hard-coding the server's expected public key or SSL certificate hash. You can use cURL's --pinnedpubkey flag to ensure the connection is only allowed if the server's presented public key exactly matches your pinned value.

While browser-based pinning has been removed due to its high risk of accidental site lockouts, cURL still supports it for high-security environments where the server’s public key is known in advance and unlikely to change.

Common cURL SSL Errors and What They Mean

Sometimes, developers may see SSL certificate errors during certificate verification. These errors tell you exactly what went wrong.

  • curl: (60) SSL certificate problem: unable to get local issuer certificate. It means cURL cannot verify the server's SSL certificate against its local list of trusted CAs. To fix it, you must either update your system's CA bundle or point cURL to a valid CA file using the --cacert flag.
  • curl: (60) self-signed certificate in certificate chain. The server is using a self-signed certificate rather than one issued by a recognized CA. Standard SSL verification fails because cURL does not inherently trust the entity that signed the certificate.
  • certificate has expired. All SSL certificates have a specific end date. It shows up when a server uses an old certificate that’s no longer active.

Safer Alternatives to --insecure

Many people simply choose to ignore SSL certificate checks using the insecure flag, but safer options exist for production environments. You should manage your SSL certificates properly.

  • --cacert /path/to/cert.pem. It lets you point cURL directly to a trusted CA certificate file, giving cURL the exact information it needs to verify the server's identity without having to turn off security checks.
  • --cert and --key (client certificate authentication). You can use these flags to securely send your own files to the server, proving both sides of identity.
  • Updating CA bundle. Sometimes your system simply has an outdated list of trusted Root CAs, so updating your operating system's or cURL's main SSL certificate bundle fixes the connection problems quickly.
  • Installing local CA certificate. You can add a custom certificate directly to your computer's trusted list, and you won’t need to ignore SSL certificate warnings for internal sites.

Risks of Ignoring SSL Verification in cURL

You’re not entirely risk-free when you choose to work with the cURL ignore SSL flag. Security layers exist to protect your sensitive data. Here are some dangers you may be exposed to:

  • Man-in-the-middle attacks. Because cURL isn't verifying identity, an attacker can actively intercept the connection, present a fake SSL certificate, and decrypt your private traffic before you even realize it.
  • Data tampering. Cyber criminals can alter the files you download or upload without your knowledge.
  • Connecting to spoofed servers. You might accidentally send passwords to a fake website.
  • Credential exposure. While your login details are still encrypted, bypassing verification means you might unknowingly establish that secure connection directly with a malicious attacker rather than your intended server.

How to Ignore cURL SSL in PHP

PHP developers often need to fetch data from test servers. To do that, you can bypass SSL certificate verification directly in your code.

You must set both the CURLOPT_SSL_VERIFYPEER and CURLOPT_SSL_VERIFYHOST options to false in your script. It stops the language from rejecting invalid certificates and bypasses the hostname match check.

$ch = curl_init();
curl_setopt($ch, CURLOPT_URL, "https://localhost/api");
curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, false);
curl_setopt($ch, CURLOPT_SSL_VERIFYHOST, false);
curl_exec($ch);
curl_close($ch);

How to Ignore cURL SSL in PowerShell

Historically, older versions of Windows PowerShell (v5.1) used cURL as an alias for the Invoke-WebRequest tool, but modern PowerShell (v6+) removed it.

If you’re using modern PowerShell (v6 or later), you can easily ignore SSL certificate problems using a specific flag:

Invoke-WebRequest -Uri "https://test-server.local" -SkipCertificateCheck

FAQ

How to fix cURL SSL connection error?

You can update or point cURL to the correct SSL certificate by using the --cacert flag. Alternatively, run cURL ignore SSL command with the flag -k or --insecure.

How do I fix “unable to get local issuer certificate”?

Use the --cacert cURL command to update or point to the correct certificate bundle. Also, you can completely ignore SSL certificate verification with the -k or --insecure cURL command, which will bypass any check.

Create Account
Share on
Article by IPRoyal
Meet our writers
Data News in Your Inbox

No spam whatsoever, just pure data gathering news, trending topics and useful links. Unsubscribe anytime.

No spam. Unsubscribe anytime.

Related articles