问题
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.
回答1:
Try with given command
openssl pkcs12 -in filename.p12 -clcerts -nokeys -out filename.crt
回答2:
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).
来源:https://stackoverflow.com/questions/52980370/how-to-convert-p12-to-crt-file