Recently I was playing around with Proxy Servers and while trying to get a HTTPS site working I needed to export my SSL Certificate from an IIS server for use on a Linux Server. Windows exports to a .pfx extension which won’t work in linux, and I would also need to extract the private key.
After a bit of googling I found the answer.
From The Windows machine.
From Start Menu click RUN then type mmc
Click FILE >> Add/Remove Snap-In
Click Certificates >> Add
Choose Computer Account
Click Next then select Local Computer and then Finish
Use + to expand the Local Computer Certificates console tree, go to the Personal directory and expand thye Certificates folder.
Right click the Certificate you need and choose All Tasks >> Export
Choose Yes, export private key and Include all certificates in certificate path if possible. (You don’t want to delete the private key unless you are SURE that you won’t need it on the server anymore. If unsure just leave it.)
Leave all other settings, and set a password. (don’t forget it!)
Save the .pfx file in your chosen location.
Now to import to Linux
Copy the .pfx file over to your Linux Server using your preferred method.
Then run the following commands. (using your file name in place of “yourcertfile”)sudo openssl pkcs12 -in yourcertfile.pfx -clcerts nokeys -out newcertfile.cersudo openssl pkcs12 -in yourcertfile.pfx -nocerts -nodes -out newkeyfile.key
Now you have 2 new files, one .cer which is your certificate, and a .key which is your private key file.
Last thing is to delete the .pfx file from the Linux server. You don’t want copies of this lying around if they aren’t needed. If you do need to keep a copy, then copy it onto an encrypted USB and keep it safe.
To delete from your Linux server, from the directory it is located just usesudo rm yourcertfile.pfx
You’re done.
