> ## Content Index
> Fetch the complete content index at: https://www.bagz.fr/llms.txt
> Use this file to discover other available public pages before exploring further.

# Extract certificate and/or key from a PKCS12 file
- URL: https://www.bagz.fr/extract-certificate-and-or-key-from-a-pkcs12-file/
- Published: 2018-09-27T20:43:48.000Z
- Updated: 2018-09-27T20:43:48.000Z
- Author: bgazui
- Tags: Linux, #Migrated-1790668826633, #wp, #wp-post, #Import 2026-09-29 08:00

The PKCS12 format is replacing the old PFX format from Microsoft. This format will allow storage of X.509 private keys and the associated public certificates in a single encrypted file.

So you can extract the key and the certificate in a single common PEM file, you can use this openssl command:

openssl pkcs12 -in myCertificate.pfx -out myCertificateAndMyKey.pem  

If you want to extract the key and the certificate independently, you can also use the options *nocerts/nokeys* along with openssl, to extract only one part:

openssl pkcs12 -in myCertificate.pfx -nocerts -out myCertificate.key  
openssl pkcs12 -in myCertificate.pfx -nokeys -out myCertificate.pem