title: openssl rsautl "unable to load Public Key"
body: <p>I generated an RSA public key in PKCS#1 <code>RSAPublicKey</code> format. I want to encrypt some data with <code>openssl rsautl</code> using this key, like so:</p>
  
  <pre><code>$ openssl genrsa -out private_key.pem 512
  Generating RSA private key, 512 bit long modulus
  ................++++++++++++
  ...++++++++++++
  e is 65537 (0x10001)
  $ openssl rsa -in private_key.pem -RSAPublicKey_out -out public_key.pem
  writing RSA key
  $ echo "this is the cleartext" | openssl rsautl -encrypt -out encrypted_with_pub_key -pubin -inkey public_key.pem
  unable to load Public Key
  </code></pre>
  
  <p>What is going on here? Why is <code>openssl</code> unable to read a key which it itself generated? What formats can it read? And more generally, why is this <a href="https://wiki.openssl.org/index.php/Manual:Rsautl(1)" rel="nofollow noreferrer">so poorly documented</a>?</p>