title: How to load a public RSA key into Python-RSA from a file?
body: <p>I generated a private and a public key using OpenSSL with the following commands:</p>
  
  <pre><code>openssl genrsa -out private_key.pem 512
  openssl rsa -in private_key.pem -pubout -out public_key.pem
  </code></pre>
  
  <p>I then tried to load them with a python script using Python-RSA:</p>
  
  <pre><code>import os
  import rsa
  
  with open('private_key.pem') as privatefile:
      keydata = privatefile.read()
  privkey = rsa.PrivateKey.load_pkcs1(keydata,'PEM')
  
  with open('public_key.pem') as publicfile:
      pkeydata = publicfile.read()
  
  pubkey = rsa.PublicKey.load_pkcs1(pkeydata)
  
  random_text = os.urandom(8)
  
  #Generate signature
  signature = rsa.sign(random_text, privkey, 'MD5')
  print signature
  
  #Verify token
  try:
      rsa.verify(random_text, signature, pubkey)
  except:
      print "Verification failed"
  </code></pre>
  
  <p>My python script fails when it tries to load the public key:</p>
  
  <pre><code>ValueError: No PEM start marker "-----BEGIN RSA PUBLIC KEY-----" found
  </code></pre>