convert .crt .key or .pfx to .pem

November 9, 2012

Objective

Convert your .crt and .key or .pfx file to a .pem file

Tools

OpenSSL– This tool will do the conversion
Note: If you have Visual SVN Server then openssl is located at:

"%VISUALSVN_SERVER%\bin\openssl"

Converting .crt .key to .pem

This section describes how to convert a .crt and .key file to .pem

Linux/Unix/MacOS/Windows

Convert .crt and .key to .pem

openssl pkcs12 -export -in /path/to/my.crt -inkey /path/to/my.key -out /path/to/my.p12
openssl pkcs12 -in /path/to/my.p12 -nodes -out /path/to/my.pem

Convert .pfx to .pem

openssl pkcs12 -in mycert.pfx -out mycert.pem -nodes

Example – convert .crt .key with password to .pem without password

root@interweb-> openssl pkcs12 -export -in /path/to/my.crt -inkey /path/to/my.key -out /path/to/my.p12
Enter Export Password:
Verifying - Enter Export Password:
root@interweb-> openssl pkcs12 -in /path/to/my.p12 -nodes -out /path/to/my.pem
Enter Import Password:
MAC verified OK
root@interweb->

Windows with Visual SVN Server

1. Convert your cert to a .pem file with the following instructions

Convert .crt and .key to .pem

"%VISUALSVN_SERVER%\bin\openssl" pkcs12 -export -in my.crt -inkey my.key -out my.p12
"%VISUALSVN_SERVER%\bin\openssl" pkcs12 -in my.p12 -nodes -out my.pem

Convert .pfx to .pem

"%VISUALSVN_SERVER%\bin\openssl" pkcs12 -in mycert.pfx -out mycert.pem -nodes

2. Copy the my.pem to “%VISUALSVN_SERVER%\certs”
3. Update “%VISUALSVN_SERVER%\conf\httpd.conf” to reflect the name of your .pem.
Example (line 106/107):

SSLCertificateFile      certs/my.pem
SSLCertificateKeyFile   certs/my.pem

4. Restart the VisualSVN service