Sunday, December 10, 2023

Extracting Private key and certificate from .PEM file using OpenSSL

OpenSSL, a popular open-source tool for working with cryptographic operations, can be used to extract the.pem and.key files from a.pfx (or.p12) file. 
The steps are as follows:

Extraction of.pem and.key from.pfx File:

Install OpenSSL as follows:

Check that your system has OpenSSL installed. You can get it from the OpenSSL website or install it with a package manager such as Homebrew on macOS or apt-get on Linux.

Conversion Method:

OpenSSL is used to extract the private key and certificate from the.pfx file.

openssl pkcs12 -in yourfile.pfx -nocerts -out privatekey.key

Change yourfile.pfx to the name of privatekey.key file. The private key will be extracted and saved to privatekey.key using this command.

openssl pkcs12 -in yourfile.pfx -clcerts -nokeys -out certificate.pem

This command will extract the certificate and save it to certificate.pem.


No comments:

Post a Comment