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