How to get the SSL certificate details for a specific domain via the command line?

Hi all,

If you wanted to see the SSL certificate information for a specific website, you could do that via your browser, by clicking on the green padlock and then click on Certificate which would open a modal with all of the information about the SSL certificate like the Common Names, the Organization that issued the certificate, the expiry date and etc.

get the SSL certificate details for a specific domain via the command line

Here’s how to do the same thing via your command line directly!

Submit an answer

This textbox defaults to using Markdown to format your answer.

You can type !ref in this text area to quickly search our full set of tutorials, documentation & marketplace offerings and insert the link!

Sign In or Sign Up to Answer

These answers are provided by our Community. If you find them useful, show some love by clicking the heart. If you run into issues leave a comment, or add your own answer to help others.

Bobby Iliev
Site Moderator
Site Moderator badge
November 29, 2020
Accepted Answer

In order to get the SSL information for a specific domain name you can use the openssl command:

  1. echo | openssl s_client -servername -connect

This would return a lot of information, which could then filter through and get the information that you need.

Another thing you could do is to put this into a small Bash script and filter through the information that you need only. You could check this Bash SSL checker tool here on GitHub.

The script provides you with the following information:

  • The domain name that the SSL certificate has been issued for
  • The number of days the SSL certificate expires in:
  • The dates when the certificate was issued on and expires on
  • The certificate has been issued by:
  • Supported TLS versions
  • Certificate Fingerprint

In order to download the script, run:

  1. wget

Then to run the script make it executable:

  1. chmod +x ssl

And then run it for your domain name:

  1. ./ssl

The output that you would get will look like this:

The domain name seems valid.

# The SSL certificate has been issued for:
Domain: CN =

# The SSL certificate expires in:
90 days

# Dates:
Issued On: Jun  4 09:05:19 2020 GMT
Expires On: Sep  2 09:05:19 2020 GMT

# The certificate has been issued by:
Issuer: C = US, O = Let's Encrypt, CN = Let's Encrypt Authority X3

# TLS supported:
|   TLSv1.0:
|   TLSv1.1:
|   TLSv1.2:

# Fingerprint:
SHA1 Fingerprint=C1:E1:6C:46:8A:74:94:14:00:94:88:B9:4B:2B:C5:90:79:DE:72:64

Here is a quick demo:

get the SSL certificate details for a specific domain via the command line

I hope that this helps! Regards, Bobby

Try DigitalOcean for free

Click below to sign up and get $200 of credit to try our products over 60 days!

Sign up

Featured on Community

Get our biweekly newsletter

Sign up for Infrastructure as a Newsletter.

Hollie's Hub for Good

Working on improving health and education, reducing inequality, and spurring economic growth? We'd like to help.

Become a contributor

Get paid to write technical tutorials and select a tech-focused charity to receive a matching donation.

Welcome to the developer cloud

DigitalOcean makes it simple to launch in the cloud and scale up as you grow — whether you're running one virtual machine or ten thousand.

Learn more
DigitalOcean Cloud Control Panel