Extract a certificate from PKCS#12 / .pfx / .pkcs12

Using openssl:

openssl pkcs12 -in infile.p12 -nokeys -out outfile.pem

This exports all certificates contained in infile.p12 to outfile.pem in PEM format. You have to enter the password used to create the PKCS#12-file. For more infos see also http://www.openssl.org/docs/apps/pkcs12.html

Extract a public key from a certificate

Ugh, why do you need a public key without the certificate? Anyway, using openssl with

openssl x509 -in mycert.pem -noout -pubkey

prints the public key to stdout in PEM format. See also http://www.openssl.org/docs/apps/x509.html

Merge a certificate and a private key into a PKCS#12

Using openssl:

openssl pkcs12 -export -in certs.pem -inkey key.pem -out outfile.p12

merges all certificates from certs.pem with the key in key.pem into the PKCS#12-file outfile.p12. See http://www.openssl.org/docs/apps/pkcs12.html

Backup a certificate

Export it from your browser/mailer/application into a PKCS#12 file and store the file safely. How to export depends on your application.

Mozilla / Seamonkey

Open the certificate manager: Edit->Preferences...->Privacy & Security->Certificates->Manage Certificates...

Press "Backup all" or select a specific certificate and press "Backup"

Thunderbird

Open the certificate manager: Edit->Settings->Privacy->Certificates

Press "Backup all" or select a specific certificate and press "Backup"

Firefox

Just like Thunderbird IIRC.

Internet Explorer / Windows

Use the "Internet Oprions" applet from the control panel, click on the "Certificates..."-Button of the "Content" tab. Select the certificate and press "Export...". Select "Yes, export private key" and PKCS#12 as the file format. If you cannot select this "Imporved Security" is activated, and there is no way for you to export the pricate key. At least no simple one. Bad luck.

I'd advise to deactivate the "Improved security" Checkbox. AFAIK this prevents that the private key can be exported again if the file is imported once more.

Restore a certificate

Usually the "Import"-Button for PKCS#15-Files is quite close to the "Export"- or "Backup"-Button.

CertificateHandling (last edited 2021-03-02 14:16:48 by MichaelKohlert)