title: How to generate the PEM serialization for the public RSA/DSA key
body: <p>Using PyCrypto I was able to generate the public and private PEM serialization for a RSA key, but in PyCrypto the DSA class has no exportKey() method.</p>
  
  <p>Trying PyOpenSSL I was able to generate the private PEM serialization for RSA and DSA keys, bu there is no crypto.dump_publickey method in PyOpenSSL.</p>
  
  <p>I am looking for suggestion of how to generate the PEM serialization for RSA and DSA keys.</p>
  
  <p>Many thanks!</p>
  
  <p>PS: meanwhile I have changed the PyOpenSSL code to also export an dump_privatekey method for crypto API. PyOpenSSL bug and patch can be found at: <a href="https://bugs.launchpad.net/pyopenssl/+bug/780089" rel="nofollow">https://bugs.launchpad.net/pyopenssl/+bug/780089</a></p>
  
  <hr>
  
  <p>I was already using Twisted.conch so I solved this problem by manually generating a DSA/RSA key using PyCrypto and then initializing a twisted.conch.ssh.key.Key using this key. The Key class from Conch provides a toString method for string serialization.</p>