You'll get SSL verification error when running cURL against https-based websites with the SSL certificates that are either misconfigured, expired, or self-signed such as the following;

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

This is because cURL will verify each SSL connection to be secure before proceeding.

To overcome this, you can use -k or the insecure option for cURL to ignore SSL certificate errors.

-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:

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

With -k in place, cURL will skip the verification process and you'll be able to request the web page albeit insecurely.

$ curl -k
<meta HTTP-EQUIV="REFRESH" content="0; url=/newpage.php">
Share this guide!
Discuss the article:

Comment anonymously. Login not required.