title: extract private key bytes in C#
body: <p>I am currently able to extract a private key from a PFX file using OpenSSL using the following commands:</p>
  
  <pre><code>openssl pkcs12 -in filename.pfx -nocerts -out privateKey.pem
  
  openssl.exe rsa -in privateKey.pem -out private.pem
  </code></pre>
  
  <p>The private.pem file begins with <code>---BEGIN RSA PRIVATE KEY---</code> and ends with <code>---END RSA PRIVATE KEY---</code></p>
  
  <p>I want to do the same in C# using .NET libraries or the Bouncy Castle library.</p>
  
  <p>How do I do this?</p>