OPENSSL – Certificate Conversion – Sertifika Türlerini Dönüştürme Pfx,Pem,Crt,Privte Key

We need to convert pfx to pem,.key,crt. So, We can use OpenSSL

OPENSSL download: https://sourceforge.net/projects/openssl/files/

cd C:\OpenSSL\bin  

PEM: private key or certificate

CER: only certificate

DER: only certificate

CRT: only certificate

PFX: private key and certificate

P12: private key and certificate

JKS: private key and certificate

KEY: public key or private key

OpenSSL commands for Certificate conversion process

Conversion Pfx to Key

openssl pkcs12 -in YourCertificate.pfx -nocerts -out FileName.key

Create Pfx with Your Private Key and CRT

 openssl pkcs12 -export -out YourCertificate.pfx -inkey YourCertificate.key -in YourCertificate.crt

Conversion Key to PEM

openssl rsa -in private.key -out private.pem -outform PEM

Conversion Pfx to Pem

openssl pkcs12 -in YourCertificate.pfx -clcerts -nokeys -out FileName.pem

Conversion Pfx to Crt

openssl pkcs12 -in YourCertificate.pfx -clcerts -nokeys -out FileName.crt

Conversion Crt to PEM

openssl x509 -in cert.crt -out cert.pem -outform PEM

(Optional) Get the Private Key from the key-pair

openssl rsa -in private_key.key -out private_key_nopass.key

Get the Public Key from key Pair

openssl rsa -in sample.key -pubout -out sample_public.key

Need to do some modification to the private key -> to pkcs8 format

openssl pkcs8 -topk8 -inform PEM -in YourFile.key -outform PEM -nocrypt
Copy the output and save it as sample_private_pkcs8.key