How To Verify SSL Certificate From A Shell Prompt

You can verify an SSL certificate from a shell prompt using the openssl command-line tool. Here’s how to do it:

  1. Open a terminal or shell prompt on your Linux or Unix system.
  2. Run the following command to check the SSL certificate of a website:
    openssl s_client -connect example.com:443

    Replace example.com with the domain name or IP address of the website you want to check. The :443 at the end specifies that the connection should use port 443, which is the default port for HTTPS connections.

  3. The output of the command will include the SSL certificate for the website. Look for the -----BEGIN CERTIFICATE----- and -----END CERTIFICATE----- lines to find the certificate. You can also use the grep command to filter the output to show only the certificate:
    openssl s_client -connect example.com:443 | openssl x509 -noout -text

    This command uses grep to filter the output of the openssl command and the openssl x509 command to show the certificate in a human-readable format.

  4. To verify that the certificate is valid, check that the output includes the following information:
    • Issuer and Subject: These fields should contain the name of the organization that issued the certificate and the name of the website, respectively.
    • Validity: This field should show the start and end dates of the certificate’s validity.
    • Signature Algorithm: This field should show the type of signature used to sign the certificate.

    If any of these fields are missing or incorrect, the certificate may be invalid or fraudulent.

That’s it! You have verified the SSL certificate for a website from a shell prompt using the openssl command-line tool.

Leave a Comment