Export public-private keys from PFX file
In this blog I'll share the snippets used to export the public key & private key from a PFX file. Sometimes we have to perform the data encryption/decryption using the digital signature by taking the public key(so called as SSL certificate or public keys) to encrypt the data and private key to decrypt the data. Let's take the sample DSCs provided by eMudhra- https://www.e-mudhra.com/Repository/ I have taken " e-Mudhra sub CA for Class 3 Individual 2014" for this blog. This zip contains two files as- Class 3 individiual test_encryption.pfx- For data encryption/decryption Class 3 individiual test_Signature.pfx- For signing the document We'll take the file Class 3 individiual test_encryption.pfx for this blog and follow the below steps to obtain the public key & private key. A linux machine with openssl utility Run the following command to extract the private key openssl pkcs12 -in Class_3_individiual_test_encryption.pfx -nocerts -out private_key.key If pr...