How to display remote SSL certificate details with CLI tools/cURL?

Better Stack Team
Updated on October 5, 2023

To display remote SSL certificate details in the console, just like you would in a browser, you can use the following solutions.

Solution 1 - Using openssl

You can use openssl command like this. Replace the highlighted part with the select domain name

 
echo | openssl s_client -showcerts -servername google.com -connect google.com:443 2>/dev/null | openssl x509 -inform pem -noout -text

Solution 2 - Using curl

Using the curl you don't get as much information but it may be what you are looking for.

 
curl --insecure -vvI https://www.google.com 2>&1 | awk 'BEGIN { cert=0 } /^\* SSL connection/ { cert=1 } /^\*/ { if (cert) print }'

Solution 3 - Using nmap

Another solution is to use nmap (needs to be installed first)

 
nmap -p 443 --script ssl-cert google.com

Make your mark

Join the writer's program

Are you a developer and love writing and sharing your knowledge with the world? Join our guest writing program and get paid for writing amazing technical guides. We'll get them to the right readers that will appreciate them.

Write for us
Writer of the month
Marin Bezhanov
Marin is a software engineer and architect with a broad range of experience working...
Build on top of Better Stack

Write a script, app or project on top of Better Stack and share it with the world. Make a public repository and share it with us at our email.

community@betterstack.com

or submit a pull request and help us build better products for everyone.

See the full list of amazing projects on github