Quantcast
Channel: How to create .pfx file containing only one of private/public key - Stack Overflow
Viewing all articles
Browse latest Browse all 4

Answer by Ankur Singhal for How to create .pfx file containing only one of private/public key

$
0
0

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 certificate from the pfx file but the generated file will contain public key certificate and some other information. To extract only public key certificate first we need to convert the pfx file to pem which contains both private and public key, and then extract the public key certificate 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

Viewing all articles
Browse latest Browse all 4

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>