How to determine SSL cert expiration date from a PEM encoded certificate?
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.
How to determine SSL cert expiration date from a PEM which have a lot of certificats concatenated on one file (pem)?
As found out in https://serverfault.com/questions/391396/how-to-split-a-pem-file#676968 something like that works:
openssl crl2pkcs7 -nocrl -certfile cert.pem | openssl pkcs7 -print_certs -text | grep -E '(Subject:|Not After)'
But the subject comes after the date.
Otherwise you need to do some shell glue using sed
, awk
or perl
for example.
How to determine SSL cert expire date from the cert file itself(.p12)
You can use openssl to extract the certificate from the .p12 file to a .pem file using the following command:
openssl pkcs12 -in certificate.p12 -out certificate.pem -nodes
Then, you can extract the expiration date from the certificate in the .pem file using the following command:
cat certificate.pem | openssl x509 -noout -enddate
Check the expiry date of a Certificate in UNIX
You could use openssl:
openssl x509 -in cert.pem -inform PEM -noout -enddate
cert.pem
should be PEM encoded. If you have DER encoded certificate (just binary data, no base64) then you can switch to -inform DER
.
More information can be found here.
Related Topics
How to Wrap Lines Within Columns in Linux
Is Kernel Space Mapped into User Space on Linux X86
Why Didn't I Get Segmentation Fault When Storing Past the End of the Bss
Explicitly Invoke Sig_Dfl/Sig_Ign Handlers on Linux
Deleting String Up to the First Occurrence of Certain Character
Command Substitution Within Sed Expression
How to Tell Qt to Use Different Openssl
Perl Fails to Set Locale Even Though It Is Installed
Where Is the Linux Isr Entry Point
Matlab Mex Socket Wrapper Library
Bash Sort - How to Sort Using Timestamp
How to Connect a Shell to a Pseudo Tty
Bash, Linux, Need to Remove Lines from One File Based on Matching Content from Another File
How to Use Stdin Twice from Pipe