I am currently able to extract a private key from a PFX file using OpenSSL using the following commands:
openssl pkcs12 -in filename.pfx -nocerts -out privateKey.pem
openssl.exe rsa -in privateKey.pem -out private.pem
The private.pem file begins with ---BEGIN RSA PRIVATE KEY--- and ends with ---END RSA PRIVATE KEY---
I want to do the same in C# using .NET libraries or the Bouncy Castle library.
How do I do this?
This is what worked for me. Should also work for you: