How to Extract CRT and KEY Files from a PFX Certificate
This guide explains how to extract .crt
(certificate) and .key
(private key) files from a .pfx
certificate bundle provided by the customer, using a Bash script with OpenSSL.
Prerequisites
The customer must provide a
.pfx
certificate file.Rename the file to match the following format:
domain.pfx
. (Example:medianova_com.pfx
)You must have OpenSSL installed on your machine.
You must know the password of the
.pfx
file.
Files Generated
domain.crt
Public certificate
domain.key
Unencrypted private key
encrypted-domain.key
Encrypted private key (temporary)
Script Usage
Save the following script as extract-cert.sh
:
Running the Script
Replace
yourPFXpassword
with the actual password provided for the.pfx
file.
Notes
The script ensures that the extracted certificate and key match by comparing their modulus values.
If you get a
FALSE
output, double-check the.pfx
file and password.
Output Example
Or, if there's a problem:
Last updated
Was this helpful?