title: Public key not recognized
body: <p>I am trying to export a public key from openssl using python.  I have the actual key information transferred to the client from the server but the PEM encoding is not transferred so the key on the client is useless.  I basically send the public key using send all in python but unfortunately this does not send the PEM encoding.  Does anyone know how to transfer the encoding? 
  I didn't know that the encoding would not transfer along with the key.</p>
  
  <p>THe code where the string is read in</p>
  
  <pre><code> import socket
  
   import M2Crypto as m2c
   import os
  
   max_transfer_block = 1024
   server_addr = "10.1.1.2"
   dest_port = 3333
   listen_port = 8888
   client_addr =  "10.1.1.3"
   mysocket = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
   mysocket.connect((server_addr, dest_port))
  
   #receive the public key from the server
   keysocket = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
   keysocket.bind((client_addr, listen_port))
   keysocket.listen(1)
   conn, client_addr = keysocket.accept()
   print 'connected by', client_addr
   data = conn.recv(max_transfer_block)
   #FILE = m2c.RSA.save_pub_key(data, "serverPubKey.pem")
  
   FILE = open("sPub.pem", "w")
   FILE.write(data)
   keysocket.close()     
  
   #transfer encrypted file
   key = m2c.RSA.load_pub_key('serverPubKey.pem')
   FILE = open("test.txt", "r")
  
   data = FILE.read()
  
   encrypted = key.public_encrypt(data, m2c.RSA.pkcs1_padding)
  
   mysocket.sendall(encrypted)
   mysocket.close()
  </code></pre>
  
  <p>When I use the line <code>key = m2c.RSA.load_pub_key('serverPubKey.pem')</code> I get an error telling me that there is no starting point.</p>
  
  <pre><code> raise RSAError, m2.err_reason_error_string(m2.err_get_error()) M2Crypto.RSA.RSAError: no start line
  </code></pre>
  
  <p>I have figured out that this is because there is not in PEM format.  Unfortunately, I don't know how to put it in that format.</p>