Search code examples
sslopensslssl-certificate

How to determine SSL cert expire date from the cert file itself(.p12)


If I have the actual file(.p12) and a Bash shell in Mac, how can I extract certificate and key file and also the certificate expiration date? assuming I have the csr(.p12), key files.


Solution

  • 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