With openssl:

openssl x509 -enddate -noout -in file.pem

The output is on the form:

notAfter=Nov  3 22:23:50 2014 GMT

Also see MikeW's answer for how to easily check whether the certificate has expired or not, or whether it will within a certain time period, without having to parse the date above.

Answer from that other guy on Stack Overflow
🌐
nixCraft
cyberciti.biz › nixcraft › howto › bash shell › how to check tls/ssl certificate expiration date from command-line
How to check TLS/SSL certificate expiration date from command-line
April 16, 2025 - See the following man pages (use the man command or help command) $ man x509 $ man s_client ... Vivek Gite is an expert IT Consultant with over 25 years of experience, specializing in Linux and open source solutions.
🌐
GitHub
gist.github.com › cgmartin › 49cd0aefe836932cdc96
Bash SSL Certificate Expiration Check · GitHub
#!/bin/bash file=$(cat /path/to/list/of/domains/list.txt) RECIPIENT="[email protected]" DAYS="3" for line in $file; do echo "checking if $line expires in less than $DAYS days"; expirationdate=$(date -d "$(: | openssl s_client -connect "$line":443 -servername "$line" 2>/dev/null \ | openssl x509 -text \ | grep 'Not After' \ |awk '{print $4,$5,$7}')" '+%s'); indays=$(($(date +%s) + (86400*DAYS))); if [ "$indays" -gt "$expirationdate" ]; then echo "expiring soon" echo "KO - Certificate for $line expires in less than $DAYS days, on $(date -d @"$expirationdate" '+%Y-%m-%d')" \ | mail -s
🌐
www.kaper.com
kaper.com › notes › check-ssl-certificate-expire-from-command-line
Check SSL Certificate Expire From Command Line – www.kaper.com
If you want to check SSL Certificate expires from the Linux command line, you can do that like this: echo | openssl s_client -showcerts -servername www.kaper.com -connect www.kaper.com:443 | openssl x509 -noout -datesCode language: Bash (bash) (Of course replace the www.kaper.com by the host ...
🌐
GeeksforGeeks
geeksforgeeks.org › linux-unix › how-to-check-tls-ssl-certificate-expiration-date-from-linux-cli
How to check TLS/SSL certificate expiration date from Linux CLI? - GeeksforGeeks
July 23, 2025 - TLS certificates typically include the following details: ... Below are the steps to view the expiration date of TLS/SSL from Linux CLI. Step 1: Open The CLI (Command-Line Interface) by pressing below keyboard keys.
🌐
Let's Encrypt
community.letsencrypt.org › help
How to find Certifications Expiry Date - Help - Let's Encrypt Community Support
December 19, 2017 - Good Morning! I have the following doubt: Which command should I run to check the expiration date of my certificates on my server? Operating System: Ubuntu Thank you!
🌐
SSL Dragon
ssldragon.com › home › tutorials › openssl tutorials › how to check the ssl certificate expiration date with openssl
How to Check the SSL Certificate Expiration Date with OpenSSL?
February 13, 2025 - You can check certificate expiration with OpenSSL on various platforms. Despite slight differences in command syntax due to operating system variations, the outputs of these commands provide crucial information about the expiration date of your SSL certificates.
🌐
Askssl
askssl.com › how-to-check-ssl-certificate-expiration-date-in-linux
How to Check SSL Certificate Expiration Date in Linux – Free SSL Certificates
You can even check expiration dates for certificates on other servers: ... Replace www.example.com with the actual hostname. If you prefer not to use the command line, various online SSL checkers exist.
Find elsewhere
🌐
SSL Dragon
ssldragon.com › home › blog › advanced ssl › how to check an ssl certificate in linux with openssl
How to Check an SSL Certificate in Linux with OpenSSL
October 27, 2025 - Here’s how to check the SSL certificate expiration date in Linux: $ echo | openssl s_client -servername howtouselinux.com -connect yourplc.com:443 2>/dev/null | openssl x509 -noout -dates · You can also use an OpenSSL command to check the ...
🌐
Beyond Co., Ltd.
beyondjapan.com › https://beyondjapan.com/en/ › blog › osaka office › how to check the expiration date of a certificate using openssl command/option explanation
How to check the certificate expiration date using openssl command and option explanation | Beyond Co., Ltd.
July 16, 2025 - *This is not an option, but a specification concerning the standard output of Shell (in this environment, bash). Use "|" (pipe) to pass it to a command that loads the contents of the SSL certificate received through communication.
🌐
SSLInsights
sslinsights.com › home › wiki › how to check ssl certificate expiration date in linux
How to Check SSL Certificate Expiration Date in Linux
May 13, 2025 - For a faster check SSL certificate expiration date in Linux: curl -Iv https://example.com 2>&1 | grep "expire date" This extracts just the expiry date from the SSL handshake. The certbot check expiration command helps manage Let’s Encrypt ...
Address   1207 Delaware Ave #2838, 19806, Wilmington
(5.0)
🌐
Askssl
askssl.com › how-to-check-ssl-certificate-expiration-date-in-ubuntu
How to Check SSL Certificate Expiration Date in Ubuntu – Free SSL Certificates
OpenSSL is the go-to cryptographic toolkit in Ubuntu (and many other Linux flavors). Here’s how to use it to display a certificate’s expiration date: ... Remember to replace certificate.pem with the actual path to your certificate file. Look for the line “Not After” in the output.
🌐
SSLInsights
sslinsights.com › home › wiki › how to check ssl certificate expiration date using openssl
How to Check SSL Certificate Expiration Date Using OpenSSL
May 13, 2025 - Users can check SSL certificate expiration using the OpenSSL command: openssl x509 -enddate -noout -in certificate.pem. This command displays the exact expiration date of the SSL certificate.
Address   1207 Delaware Ave #2838, 19806, Wilmington
(5.0)
🌐
How to Use Linux
howtouselinux.com › home › 5 ways to check ssl certificate expiration date
5 Ways to Check SSL Certificate Expiration date - howtouselinux
August 28, 2021 - The openssl s_client command implements a generic SSL/TLS client which connects to a remote host using SSL/TLS. It is a very useful diagnostic tool for SSL servers. It checks whether the certificate is valid, trusted, and complete. ... If an SSL certificate expires, the website will not be ...