Can anyone tell me the correct way/command to extract/convert the certificate .crt file from a .p12 file? After I searched. I found the way how to convert .pem to .crt. but not found .p12 to .crt.
How to open a P12 file. To install a p12 key on a Windows or Mac PC, simply double-click the file. The Certificate Import Wizard (Windows) or Add Certificates Wizard (Mac) will appear to guide you through installing the key.
PKCS#12 (P12) files define an archive file format for storing cryptographic objects as a single file. API Connect supports the P12 file format for uploading a keystore and truststore. The keystore should contain both a private and public key along with intermediate CA certificates.
Try with given command
openssl pkcs12 -in filename.p12 -clcerts -nokeys -out filename.crt
You tagged 'keytool'. If you mean Java keytool, which is not the only one, it can do this:
keytool -keystore in.p12 -storetype pkcs12 -exportcert -file out.crt -rfc -alias $name
# for java9 up omit -storetype pkcs12 -- it's now default
# -rfc gives PEM form; omit for DER form
# can omit -alias $name if 'friendlyname' is mykey --
# but that's likely only for stores created _with_ keytool
# because other tools and users mostly don't use that name
(but personally I'd use openssl
as in crack_it's answer).
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With