
Knowing the expiry date of your SSL certificate is absolutely critical for maintaining secure and uninterrupted connections to your website or service. Letting an SSL certificate expire can lead to security warnings for users, loss of trust, and potential downtime. Fortunately, if you have the certificate file itself, you can quickly determine its expiration without needing to access a web server or use online checkers.
The most common and effective way to extract this information directly from the file is by using the command line tool openssl. This versatile utility is available on most Unix-like systems (Linux, macOS) and can also be installed on Windows.
Here’s how you can get the expiry date using the openssl command:
Open your terminal or command prompt.
Navigate to the directory where your SSL certificate file is located.
Use the following command, replacing
your_certificate_file.crt
with the actual name of your certificate file (it might have a.pem
,.cer
, or other extension):openssl x509 -in yourcertificatefile.crt -noout -dates
Let’s break down the command:
- openssl: Invokes the OpenSSL program.
- x509: Specifies that you are working with an X.509 certificate.
- -in your_certificate_file.crt: Tells openssl to read the certificate from the specified input file.
- -noout: Prevents openssl from outputting the encoded version of the certificate.
- -dates: Instructs openssl to specifically display the validity periods of the certificate.
After executing this command, you will typically see output similar to this:
notBefore=Mar 15 10:00:00 2023 GMT
notAfter=Mar 14 10:00:00 2024 GMT
The notBefore date indicates when the certificate became valid, and the notAfter date is the expiry date. The notAfter date is the one you need to pay close attention to for renewal planning.
This simple command line method provides a fast and direct way to check the validity of any SSL certificate file you have access to, ensuring you can manage your certificate lifecycle effectively and avoid unexpected expiration issues.
Source: https://kifarunix.com/check-ssl-certificate-expiry-date-from-certificate-file/