title: Extracting public key from private key in OpenSSL
body: <p>I need to extract the RSA public key from a RSA private key using OpenSSL.</p>
  
  <p>I'm currently using <code>RSAPublicKey_dup()</code> passing the <code>RSA*</code> private key to get the public key. However, while the call seems to work, I cannot load (or use) this public key using the openssl command-line tool.</p>
  
  <p>If I generate the public key using the command-line tool ("<code>$ openssl rsa -in private.pem -pubout &gt; public.pem</code>"), I can use it and it works like a charm.</p>
  
  <p>Do you guys know how I can get this work ? Maybe another function ? The OpenSSL documentation is quite hard to browse...</p>
  
  <p>Thank you.</p>