title: How to generate PKCS#1 RSA keys in PEM Format?
body: <p>Sorry for my english and honestly I have a very little understanding on this so please bear with me. </p>
  
  <p>I am developing a java application that sends a signed request to a Server.
  To do so, I have to generate a <em>PKCS#1 RSA</em> key pair in <code>PEM</code> format for signing and verification. I've tried using <em>OpenSSL v.1.0.1</em>. but the public key generated is a <code>X.509 PEM</code>.</p>
  
  <p>Here's the openssl command I used to generate the keys:</p>
  
  <p><strong>Private Key</strong>:</p>
  
  <pre><code>openssl genrsa -out name_of_private_key.pem 1024
  </code></pre>
  
  <p><strong>Public Key</strong></p>
  
  <pre><code>openssl rsa -in name_of_private_key.pem -pub out &gt; name_of_public_key.pem
  </code></pre>
  
  <p>I've gone through this thread also and I found an open source JAVA library BouncyCastle: <a href="https://stackoverflow.com/questions/7611383/generating-rsa-keys-in-pkcs1-format-in-java?answertab=oldest#tab-top">Generating RSA keys in PKCS#1 format in Java</a></p>
  
  <p>But it says that BouncyCastle is only for PKCS#1 <em>padding</em> not <em>encoding</em>.</p>
  
  <p>Preferably, I'm looking for ways to generate it using JAVA or any third parties if no other option is available.</p>