How to display a remote SSL certificate details using CLI tools?

Better Stack Team
Updated on November 9, 2023

You can use various command-line tools to display details of a remote SSL certificate. One common tool is openssl, which provides commands to fetch and examine SSL certificates.

Here's an example of how to use openssl s_client to view SSL certificate details of a remote server:

 
openssl s_client -connect example.com:443

Replace example.com with the domain name or IP address of the remote server you want to examine. This command initiates an SSL connection to the specified server and prints out the certificate details.

If you only want to see the certificate details without initiating an SSL connection, you can use the following:

 
echo | openssl s_client -showcerts -connect example.com:443 2>/dev/null | openssl x509 -text

This command will fetch the SSL certificate from the remote server and display its details.

Another method involves using the gnutls-cli tool:

 
gnutls-cli --print-cert example.com

Replace example.com with the domain name or IP address you wish to check.

Additionally, the curl command can be used to fetch and display the SSL certificate details:

 
curl -v <https://example.com>

This will display verbose output that includes SSL certificate information.

Remember to replace example.com with the actual domain you want to examine. These tools can provide detailed information about the SSL certificate, such as the certificate chain, expiration date, issuer information, and more.