title: Converting binary private key into pem format
body: <p>I'm trying to import a certificate into AWS, the problem is my private key is not in pem format. I'd rather not have to create a new certificate as I've already had a CA sign mine. I've generated the key using this following command </p>
  
  <pre><code>keytool -genkey -alias info -keyalg RSA -keysize 2048 -keystore info
  </code></pre>
  
  <p>Which leaves me with a private key in binary format named info. I'm able to use this command to convert the private key into base64 I believe. </p>
  
  <pre><code> openssl rsa -inform DER -outform PEM -in info -out info.pem
  </code></pre>
  
  <p>The header and footer are missing </p>
  
  <pre><code>-----BEGIN RSA PRIVATE KEY-----
  
  -----END RSA PRIVATE KEY-----
  </code></pre>
  
  <p>Which I append to their appropriate locations. Now when I'm attempt to upload my cert, it fails because the private key is not in pem format. AS per other questions regarding binary to pem format, I've tried this command.</p>
  
  <pre><code>openssl rsa -inform der -in info -outform pem -out info.pem
  </code></pre>
  
  <p>which results in this error "unable to load Private Key
  140594255303104:error:0D07207B:asn1 encoding routines:ASN1_get_object:header too long:../crypto/asn1/asn1_lib.c:101:" </p>
  
  <p>How should go about converting a binary key generated from keytool into pem format?</p>