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

Better Stack Team
Updated on May 4, 2022

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
Copied!

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 }'
Copied!

Solution 3 - Using nmap

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

nmap -p 443 --script ssl-cert google.com
Copied!
Got an article suggestion? Let us know
Explore more
Licensed under CC-BY-NC-SA

This work is licensed under a Creative Commons Attribution-NonCommercial-ShareAlike 4.0 International License.

We are hiring.

Software is our way of making the world a tiny bit better. We build tools for the makers of tomorrow.

Explore all positions →

Reliability is the
ultimate feature

Delightful observability tools that turn your logs & monitoring into a secret weapon for shipping better software faster.

Explore Better Stack