How to Convert PFX to .CRT and .KEY Files Using OpenSSL: Step-by-Step Guide

Learn how to convert PFX files to .CRT and .KEY formats using OpenSSL in this easy step-by-step guide. Extract private keys for free with commands.6 min


pfx-to-crt-and-key-java-openssl-9Mood-beingcoders

TL;DR — This 7-minute guide will help you convert your .pfx file into .crt or .key file from the encrypted key using OpenSSL Commands for free. I kept 3 minutes as a buffer 😉. Using this trick, You can —

  • Convert PFX to CRT
  • Convert PFX to KEY
  • Extract private key from PFX
  • OpenSSL commands for SSL certificates
  • Convert PFX file to CRT
  • Extract private key OpenSSL
  • SSL certificate conversion
  • PFX to PEM conversion

Are you looking for extracting private key from PFX? — You are on right place.

Install OpenSSL:

OpenSSL is a robust, commercial-grade, and full-featured toolkit for the Transport Layer Security (TLS) and Secure Sockets Layer (SSL) protocols. It is also a general-purpose cryptography library. For more information, you can visit the official website.

Let’s say, you have already got the .pfx certificate from the SSL providers/registrars like network solution, godaddy, bigrock etc., then you are good to follow up the below steps without any hurdles.

You need to follow up below commands in order to convert files to .crt/.key easily.

Prerequisites for Converting PFX Files

  1. OpenSSL package must be installed in your system.
  2. You must have .pfx file for your chosen domain name.
  3. Windows/Ubuntu/Linux system to utilize the OpenSSL package with crt

Step 1: Extract private key from PFX

  • Question: How do I extract a private key from a PFX file using OpenSSL?
  • Answer: You can extract the private key from a PFX file using the following OpenSSL command:
openssl pkcs12 -in [yourfilename.pfx] -nocerts -out [keyfilename-encrypted.key]

This command will extract the private key from the .pfx file. Now we need to type the import password of the .pfx file. This password is used to protect the keypair that was created for the .pfx file. After entering the import password OpenSSL requests to type another password twice. This new password is to protect the .key file. #SafetyFirst

theraxton@ubuntu:~/Downloads/SSL-certificate$ openssl pkcs12 -in samplefilename.pfx -nocerts -out samplefilenameencrypted.key 
Enter Import Password: 
Enter PEM pass phrase: 
Verifying — Enter PEM pass phrase: 
theraxton@ubuntu:~/Downloads/SSL-certificate$

Please note that, when you are going to enter the password, you can’t see against password, but they are typing in the back. Press enter once you entered your secure password.

Step 2: Convert PFX to CRT [Extract .crt file from the .pfx certificate]

openssl pkcs12 -in [yourfilename.pfx] -clcerts -nokeys -out [certificatename.crt]

After that, press enter and give the password for your certificate, and hit enter again, after all — your certificate will appear in the same directory.

theraxton@ubuntu:~/Downloads/SSL-certificate$ openssl pkcs12 -in samplefile.pfx -clcerts -nokeys -out samplefileencrypted.crt 
Enter Import Password:

Step 3: Convert PFX to KEY [Generate .KEY File Using OpenSSL]

[Extract the .key file from the encrypted private key from step 1]

openssl rsa -in [keyfilename-encrypted.key] -out [keyfilename-decrypted.key]

We need to enter the import password which we created in step 1. Now we have a certificate(.crt) and the two private keys ( encrypted and unencrypted).

theraxton@ubuntu:~/Downloads/SSL-certificate$ openssl rsa -in samplefilenameencrypted.key -out samplefilenameunencrypted.key 
Enter pass phrase for samplefilenameencrypted.key: 
writing RSA key

Now that you have successfully converted your PFX file into .crt and .key files, you can seamlessly use them in your Node / Angular / Java applications. Have any issues? Drop a comment below!


If you find joy and value in what I do, please consider supporting my work with a donation — however much you can afford, it means and helps more than you can imagine.

Buy Me A Coffee

All in One solution - For all conversions of PFX, CRT and private Key.

  • create pfx file from crt and key
  • convert crt to pfx without private key
  • openssl pfx to crt and key
  • convert crt to pfx with private key
  • convert pfx to crt and key
  • create pfx file from crt and key online
  • openssl convert pfx to crt and key
  • convert crt and key to pfx
  • convert crt to cer with private key
  • convert pfx certificate to crt and key
  • openssl pfx to crt and key
  • convert pfx certificate to crt and key file windows
  • openssl convert pfx to crt and key with password
  • openssl convert crt to pfx with private key
  • openssl crt to pfx with private key
  • openssl pfx from crt and key
  • openssl convert pfx to crt and key
  • create pfx file from crt and key
  • convert crt to pfx without private key
  • pfx to crt and key openssl

adsense


Discover more from 9Mood

Subscribe to get the latest posts sent to your email.


Like it? Share with your friends!

What's Your Reaction?

Lol Lol
0
Lol
WTF WTF
0
WTF
Cute Cute
3
Cute
Love Love
3
Love
Vomit Vomit
0
Vomit
Cry Cry
0
Cry
Wow Wow
3
Wow
Fail Fail
0
Fail
Angry Angry
0
Angry
Rakshit Shah

Legend

Hey Moodies, Kem chho ? - Majama? (Yeah, You guessed Right! I am from Gujarat, India) 25, Computer Engineer, Foodie, Gamer, Coder and may be a Traveller . > If I can’t, who else will? < You can reach out me by “Rakshitshah94” on 9MOodQuoraMediumGithubInstagramsnapchattwitter, Even you can also google it to see me. I am everywhere, But I am not God. Feel free to text me.

0 Comments

Leave a Reply

Choose A Format
Story
Formatted Text with Embeds and Visuals
List
The Classic Internet Listicles
Ranked List
Upvote or downvote to decide the best list item
Open List
Submit your own item and vote up for the best submission
Countdown
The Classic Internet Countdowns
Meme
Upload your own images to make custom memes
Poll
Voting to make decisions or determine opinions
Trivia quiz
Series of questions with right and wrong answers that intends to check knowledge
Personality quiz
Series of questions that intends to reveal something about the personality
is avocado good for breakfast? Sustainability Tips for Living Green Daily Photos Taken At Right Moment