Generate Pfx File From Private Key
Jul 09, 2019 If the Private Key key file is lost, you’ll need to reissue your Certificate. Can I generate a new Private Key for my Certificate if I lose the old one? You can generate a new private key and CSR, or use the automatic CSR and key generation during Certificate reissue (this option is available for all Certificates except for the Multi. How to merge certificate and private key to a PKCS#12(PFX) file Hello S-1-1-0, PowerShell Crypto Guy still here and today we will talk about the subject. Sometimes you have to use 3rd party applications/tools for certificate request generation.
Howto convert a PFX to a seperate .key/.crt file
In this article I’m going to show you the commands you need to convert your .PFX Certificate file to a seperate certificate and keyfile. This article can come in handy when you need to import your certificates on devices like Cisco routers/loadbalancers etc. where you probably need to import the certificates and keyfiles in plain text (unencrypted). My tool of choice (but there might be others) is OpenSSL for Windows, which can be downloaded here
So after you installed OpenSSL you can start it from it’s Bin folder. I’d like to put OpenSSLBin in my path so I can start it from any folder. Fire up a command prompt and cd to the folder that contains your .pfx file. First type the first command to extract the private key:
openssl pkcs12 -in [yourfile.pfx] -nocerts -out [keyfile-encrypted.key]
What this command does is extract the private key from the .pfx file. Once entered you need to type in the importpassword of the .pfx file. This is the password that you used to protect your keypair when you created your .pfx file. If you cannot remember it anymore you can just throw your .pfx file away, cause you won’t be able to import it again, anywhere!. Once you entered the import password OpenSSL requests you to type in another password, twice!. This new password will protect your .key file.
Now let’s extract the certificate:
openssl pkcs12 -in [yourfile.pfx] -clcerts -nokeys -out [certificate.crt]
Just press enter and your certificate appears.
Now as I mentioned in the intro of this article you sometimes need to have an unencrypted .key file to import on some devices. I probably don’t need to mention that you should be carefully. If you store your unencrypted keypair somewhere on an unsafe location anyone can have a go with it and impersonate for instance a website or a person of your company. So always be extra careful when it comes to private keys! Just throw the unencrypted keyfile away when you’re done with it, saving just the encrypted one.
The command:
openssl rsa -in [keyfile-encrypted.key] -out [keyfile-decrypted.key]
Again you need to enter an import password. This time you need to enter the new password that you created in step 1. After that you’re done. You decrypted your private key. In the folder you ran OpenSSL from you’ll find the certifcate (.crt) and the two private keys (encrypted and unencrypted).
Update 07-07-2014:
In some cases you might be forced to convert your private key to PEM format. You can do so with the following command:
openssl rsa -in [keyfile-encrypted.key] -outform PEM -out [keyfile-encrypted-pem.key]
Good Luck!
Tags:
.crtcertificatesconvert pfx tocreate pfx filehowtokeyopensslpfxpkcs12pkirsaLeave a Reply
Exporting Your SSL Certificate from a Microsoft Server for Importing to Another Microsoft Server
Background
Windows servers use .pfx files that contain the public key file (SSL certificate file) and the associated private key file. DigiCert provides your SSL certificate file (public key file). You use your server to generate the associated private key file as part of the CSR.
You need both the public and private keys for an SSL certificate to function. So, if you need to transfer your SSL certificates from one server to another, you need to export is as a .pfx file.
Export Prerequisite
To create a .pfx file, the SSL certificate and its corresponding private key must be on the same computer/workstation. You may need to import the certificate to the computer that has the associated private key stored on it. (e.g., the laptop/desktop computer where you created the CSR) before you can successfully export it as a .pfx file.
For help importing the certificate, see SSL Certificate Importing Instructions: DigiCert Certificate Utility.
How to Export Your SSL Certificate w/Private Key Using the DigiCert Certificate Utility
These instructions explain how to export an installed SSL certificate from a Microsoft server and its corresponding private key as a .pfx file for importing to another server. If you need your SSL Certificate in Apache .key format, please see Export a Windows SSL Certificate to an Apache Server (PEM Format).
On your Windows Server, download and save the DigiCert® Certificate Utility for Windows executable (DigiCertUtil.exe).
Run the DigiCert® Certificate Utility for Windows (double-click DigiCertUtil). Generate ssh key windows video.
In the DigiCert Certificate Utility for Windows©, click SSL (gold lock), select the certificate that you want to export as a .pfx file, and then click Export Certificate.
In the Certificate Export wizard, select Yes, export the private key, select pfx file, and then check Include all certificates in the certification path if possible, and finally, click Next.
A .pfx file uses the same format as a .p12 or PKCS12 file.
Note: If the Yes, export the private key option is grayed out (not unusable), the certificate's matching private key is not on that computer. This prevents you from being able to create the .pfx certificate file. To fix this problem, you will need to import the certificate to the same machine where the certificate's CSR was created. See Export Prerequisite.
In the Password and Confirm Password boxes, enter and confirm your password, and then, click Next.
Note: This password is used when you import this SSL certificate onto other Windows type servers or other servers or devices that accept a .pfx file.
In the File name box, click … to browse for and select the location and file name where you want to save the .pfx file, provide a file name (i.e. mySSLCertificate), click Save, and then, click Finish.
After you receive the 'Your certificate and key have been successfully exported' message, click OK.
Import PFX Certificate into Microsoft Windows Server and Configure it
To import your certificate to your server using the DigiCert Certificate Utility, you need to follow the instructions for that particular server type:
IIS 10 | Exchange 2013 |
IIS 8 | Exchange 2010 |
IIS 7 | Exchange 2007 |
IIS 6 |
Troubleshooting
After importing your certificate on to the new server, if you run into certificate errors, try repairing your certificate trust errors using DigiCert® Certificate Utility for Windows. If this does not fix the errors, contact support.
Test Your Installation
Create Pfx File From Crt And Private Key
To verify that the installation is correct, use our DigiCert® SSL Installation Diagnostics Tool and enter the DNS name of the site (e.g., www.yourdomain.com, or mail.yourdomain.com) that you are securing to test your SSL certificate.