Convert SSL certificate from PFX to PEM (OpenSSL)

Install OpenSSL
Open PowerShell and cd to OpenSSL install location - 

C:\Program Files\OpenSSL-Win64\bin

Extract private key with password (encrypted) - 

.\openssl pkcs12 -in certificate.pfx -nocerts -out privatekey.pem

OR

Extract private key without password (unencrypted) - 

.\openssl rsa -in privatekey.pem -out privatekey-nopass.pem

Extract certificate - 

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

Combine Certificate and Private key (if required) - 

Get-Content privatekey_unencrypted.pem, certificate.pem | Set-Content fullcertificate.pem

No comments: