title: Parsing certificates with bouncycastle
body: <p>I'm a certificate noob. I've been trying to import certificates for the past couple of hours and the more I dig into security stuff, the more it feels impossible to understand.</p>
  
  <p>Here is what I'm trying to achieve in java:</p>
  
  <ul>
  <li>the user can upload any kind of formatted certificate with an optional passphrase</li>
  <li>I need to convert the certificate to a non-binary PEM format</li>
  <li>Extract the private and public keys to store in a database, throw error if missing one of the two</li>
  </ul>
  
  <p>So far I've been able to parse some certificates using java security's x509Certificate but I can't get the private key. I've also tried bouncy castle but no success there either.</p>
  
  <p>Thanks for your help</p>