Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Save refo/07f13ca2762037f802f2d7453235bc68 to your computer and use it in GitHub Desktop.
Save refo/07f13ca2762037f802f2d7453235bc68 to your computer and use it in GitHub Desktop.
Extracting Certificate and Private Key Files from a .pfx File

Requirements

System with OpenSSL installed

Introduction

The *.pfx file is in PKCS#12 format and includes both the certificate and the private key. More information about the format could be found here

Export the Private Key

openssl pkcs12 -in certname.pfx -nocerts -out key.pem -nodes

Remove the Passphrase From the Private Key

openssl rsa -in key.pem -out server.key 

Export the Certificate

openssl pkcs12 -in certname.pfx -nokeys -out cert.pem

source

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment