explode aka export with openssl pfx to standard ssl files for everything else

PFX is PKCS#12 certificate ( all stuff in single file ) on everything else than IIS SSL directives need separated KEY , CERT and CAroot or CAbundles.

Happy sqares with glasses ditribute PFX files as solution for privacy and security. Who am I to argue this ? Anyway it’s the most painfull operation to insert certs and keys on other HTTPdaemons, followin copy and paste ( replace with yours! ) strings

# extract certificate
$openssl pkcs12 -in INPFX.pfx -clcerts -nokeys | sed -ne '/-BEGIN CERTIFICATE-/,/-END CERTIFICATE-/p' > host.crt
#extract key
openssl pkcs12 -in INPFX.pfx -nocerts -nodes | sed -ne '/-BEGIN PRIVATE KEY-/,/-END PRIVATE KEY-/p' > host.key
#sure or not , check if a bundle is included
openssl pkcs12 -in INPFX.pfx -cacerts -nokeys -chain | sed -ne '/-BEGIN CERTIFICATE-/,/-END CERTIFICATE-/p' > bundle.crt

Now all your needs are in place and you can insert where you want

Torna in alto