Is it possible to extract the expiration date from a private key (.p12 file) without knowing the password? I used the command bellow without success:
openssl pkcs12 -in test.p12 -nokeys -nomacver
Is it possible to extract the expiration date from a private key (.p12 file) without knowing the password? I used the command bellow without success:
openssl pkcs12 -in test.p12 -nokeys -nomacver
From my understanding, .p12 is a very flexible file format in that a p12 created by openssl can look very different from a p12 created by java keytool, but most often the contents look like this:
You need to extract the certificate, not the private key. Keys themselves don't have expiration dates, you want to extract the certificate from the p12 and look at the notAfter
or validTo
field.
My understanding is that if you created the p12 with a password, then the entire contents are encrypted as one blob. ie there is no way to access the only the certificates without knowing the password.
I'm not an openssl expert, but this seems consistent with this openssl command-line guide, which acts on the p12 certificate and private key together:
# Check a PKCS#12 file (.pfx or .p12)
openssl pkcs12 -info -in keyStore.p12
# Convert a PKCS#12 file (.pfx .p12) containing a private key and certificates to PEM
openssl pkcs12 -in keyStore.pfx -out keyStore.pem -nodes