Here’s a script which uses /expect/ to convert a PFX to PEM files:

!– HTML generated using hilite.me –><div style="background: #f0f0f0; overflow:auto;width:auto;border:solid gray;border-width:.1em .1em .1em .8em;padding:.2em .6em;"><table><tr><td><pre style="margin: 0; line-height: 125%"> 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23</pre></td><td><pre style="margin: 0; line-height: 125%">#!/usr/bin/expect -f set filename [lindex $argv 0]; set timeout -1 spawn openssl pkcs12 -in $filename -nocerts -out temp expect "Enter Import Password:" send – "\n" expect "Enter PEM pass phrase:" send – "D4ndyB0y$\n" expect "Verifying - Enter PEM pass phrase:" send – "D4ndyB0y$\n" expect eof spawn openssl rsa -in temp -out $filename-privatekey.pem expect "Enter pass phrase for temp:" send – "D4ndyB0y$\n" expect eof spawn openssl pkcs12 -in $filename -clcerts -nokeys -out $filename-cert.pem expect "Enter Import Password:" send – "\n" expect eof spawn openssl pkcs12 -in $filename -cacerts -nokeys -chain -out $filename-intermediate.pem expect "Enter Import Password:" send – "\n" expect eof

</pre></td></tr></table></div>