Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to convert .p12 to .crt file?

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.

like image 398
user3130007 Avatar asked Oct 25 '18 02:10

user3130007


People also ask

How do I open a P12 certificate?

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.

What is .P12 file?

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.


2 Answers

Try with given command

openssl pkcs12 -in filename.p12 -clcerts -nokeys -out filename.crt
like image 132
Mesar ali Avatar answered Sep 21 '22 13:09

Mesar ali


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).

like image 23
dave_thompson_085 Avatar answered Sep 21 '22 13:09

dave_thompson_085