SSL certificates are now a requirement for any website. If you don’t encrypt your site, browsers will flag it as not secure, leaving visitors with an annoying warning message. But even if you add an SSL certificate, managing it is tricky. An SSL error may pop up unexpectedly, causing you all sorts of trouble.

To avoid SSL outages, you should monitor your SSL certificate frequently and always replace it on time. And, with certs expiring in one year, this task can become quite a chore. Thankfully, there are SSL tools to help you manage your certificates, and not a single program does a better job than the versatile OpenSSL utility.

With OpenSSL, you can apply for your digital certificate (Generate the Certificate Signing Request) and install the SSL files on your server. You can also convert your certificate into various SSL formats, as well as do all kinds of verifications. In this article, we’ll show you how to verify SSL certificate details using OpenSSL in Linux. 

Most Linux systems will have OpenSSL pre-installed, but it’s better to ensure you have the latest running version. You can check your OpenSSL version by running the following command: 

openssl version –a

Certificate files in Linux are located by default in the /etc/pki/tls/certs folder or sometimes within an application-specific folder such as /etc/httpd for Apache. These generally use .pem or .crt extensions and will likely be named yourdomain.pem or yourdomain.crt, but sometimes the generic “server” file name is used as well. If you’ve applied for the SSL certificate and installed it on the server, you should already know its location and file names.

Check the full details of the certificate

OpenSSL provides a rich variety of commands to generate, install, and manage certificates. To check the details of a particular certificate, run the following command:

openssl x509 -in (path to certificate and certificate filename) -text -noout

Here’s what you should see:



Version: 3 (0x2)

Serial Number:


Signature Algorithm: sha256WithRSAEncryption

Issuer: C=US, O=DigiCert, Inc, CN=DigiCert SHA2 


Not Before: Jun 31 23:32:14 2021 GMT

Not After : Jun 31 23:32:14 2022 GMT

Subject: C=US, ST=CA, L=Sacramento, O=Yourplc, OU=IT,

Subject Public Key Info:

Public Key Algorithm: rsaEncryption

Public-Key: (2048 bit)










Show the SSL certificate itself (encoded):

$ echo | openssl s_client -servername -connect 2>/dev/null | openssl x509







Verify if the Keys Match

To verify the public and private keys match, you need to extract the public key from each file and generate a hash output for it. All three files should share the same public key and the same hash value.

Use the following commands to generate a hash of each file’s public key:

openssl pkey -pubout -in privateKey.key | openssl sha256

openssl req -pubkey -in CSR.csr -noout | openssl sha256

openssl x509 -pubkey -in certificate.crt -noout | openssl sha256

Check who issued the SSL certificate

$ echo | openssl s_client -servername -connect 2>/dev/null | openssl x509 -noout -issuer

issuer= /C=US/DigiCert Inc/CN=DigiCert SHA2

Check whom the SSL certificate is issued to

$ echo | openssl s_client -servername .com -connect 2>/dev/null | openssl x509 -noout -subject

 Subject= /

Check the validity of the SSL certificate

$ echo | openssl s_client -servername -connect 2>/dev/null | openssl x509 -noout -dates

notBefore=Jun 31 23:32:14 2021 GMT

notAfter=Jun 31 23:32:14 2022 GMT

Display the all above info about the SSL certificate

$ echo | openssl s_client -servername -connect 2>/dev/null | openssl x509 -noout -issuer -subject -dates

echo | openssl s_client -servername -connect 2>/dev/null | openssl x509 -noout -issuer -subject -dates

issuer= /C=US/O=DigiCert Inc/CN=DigiCert SHA2

subject= /

notBefore=Jun 31 23:32:14 2021 GMT

notAfter=Jun 31 23:32:14 2022 GMT

Final Words

If something goes wrong with your SSL connection, verifying your certificate’s details is the first step towards finding the culprit. In OpenSSL, you have a great utility to perform all kinds of checks, from inspecting the certificate issuer to analyzing technical data and seeing when the certificate expires. OpenSSL integrates with Linux and provides control over SSL installation via its flexible command lines.