curl by default will verify each SSL connection to be secure on every connection. You'll get the following SSL verification error when running cURL against https-based websites with the SSL certificates that are either misconfigured, expired, or self-signed.

$ curl https://www.example.com/
curl: (51) Unable to communicate securely with peer: requested domain name does not match the server's certificate.

$ curl https://www.example.com
curl: (60) SSL: no alternative certificate subject name matches target host name 'www.example.com'
More details here: https://curl.haxx.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 web page mentioned above.

You can force curl to ignore ssl certificate errors by using -k or the insecure option.

-k, --insecure
       (TLS) By default, every SSL connection curl makes is verified to be secure. This option allows curl to proceed and operate even for server connections otherwise considered insecure.

       The server connection is verified by making sure the server's certificate contains the right name and verifies successfully using the cert store.

       See this online resource for further details:
        https://curl.haxx.se/docs/sslcerts.html

       See also --proxy-insecure and --cacert.

curl will ignore SSL checks when initiating connection using the insecure option and you'll be able to bypass any SSL error that any site might have.

$ curl -k https://www.example.com/
<html>
<head>
<meta HTTP-EQUIV="REFRESH" content="0; url=/newpage.php">
</head>
</html>

Support us on Patreon if this guide has helped you. Thanks!!!

Discuss the article:

Comment anonymously. Login not required.

Share!