Follow below steps to extract public key certificate and private key from a PFX file:
Download and install OPEN SSL.
To extract the private key:
Openssl.exe pkcs12 -in <pfx_file_name>.pfx -nocerts -out priv.pem
The generated private key file (priv.pem) will be password protected, to remove the pass phrase from the private key.
Openssl.exe rsa -in priv.pem -out priv.pem
Next step is extracting the public key certificate from the pfx file, there is a direct command in OPENSSL to extract the public key from the pfx file but the generated file will contain public key and some other information. To extract only public key first we need to convert the pfx file to pem which contains both private and public key, and then extract the public key from this pem file:
openssl.exe pkcs12 -in ClientCert1.pfx -out privpub.pem
The generated pem contains both private and public keys, use the following command to extract only the public key certificate:
openssl x509 -inform pem -in privpub.pem -pubkey -out pub.pem -outform pem
Good article. Helped me a lot
ReplyDeleteReally Very helpful !
ReplyDeleteSpeciaally for setting up Amazon elb coz u require private & public Key...
Thank u so much for uploading !
Hi There,
ReplyDeleteThanks a lot.
When I issue the first command, I get permission denied, could you possibly help me?
Thanks & Regards,
Jerome