title: pyOpenSSL creating a pem file
body: <p>I've created a key pair using the following code in python with pyOpenSSL:</p>
  
  <pre><code>from OpenSSL import crypto
  k = crypto.PKey()
  k.generate_key(crypto.TYPE_RSA, 2048)
  </code></pre>
  
  <ol>
  <li>Now how can I create the private and public key .pem files from the key object?</li>
  <li>If there is any tutorial available please let me know. I found none. From the manual, it's difficult to know as I'm new to OpenSSL.</li>
  <li>What are the chances that the same code will create two same key pairs is there is no specific unique key is being used in RSA?</li>
  </ol>