Skip to content

Converting PKCS#12 (.pfx) to PEM with OpenSSL

Overview

This guide will show you how to convert a PKCS#12 file to PEM format using OpenSSL.

Conversion

Extract private and public key to PEM (no encryption/password):

Terminal window
openssl pkcs12 -in certificate.pfx -out certificate.pem -nodes

Extract public key to PEM:

Terminal window
openssl pkcs12 -in certificate.pfx -clcerts -nokeys -out certificate.pem -nodes

Extract private key to PEM:

Terminal window
openssl pkcs12 -in certificate.pfx -nocerts -out key.pem

Extract private key to PEM (no encryption/password):

Terminal window
openssl pkcs12 -in certificate.pfx -nocerts -out key.pem -nodes