How to skip SSL verification error in curl

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.

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