title: A client error (MalformedCertificate) occurred when calling the UploadServerCertificate operation: Private key was in an unrecognized format
body: <p>I am trying to setup an SSL on AWS coudfront, but have this error, <code>A client error (MalformedCertificate) occurred when calling the UploadServerCertificate operation: Private key was in an unrecognized</code> format., when running the following command:</p>
  
  <pre><code>aws iam upload-server-certificate --server-certificate-name domain.tld --certificate-body file:///home/khine/certs/14595113.crt --private-key file:///home/khine/certs/domain.key --certificate-chain file:///home/khine/Sandboxes/Business/certs/domain.tld.bundle.crt --path /cloudfront/domain.tld/
  </code></pre>
  
  <p>this is how i setup got my files:</p>
  
  <pre><code>openssl ecparam -out domain.key -name secp384r1 -genkey
  openssl req -new -sha256 -key doamin.key -nodes -out domain.tld_ssl.csr
  </code></pre>
  
  <p>then i user the csr file created to get the certificate for my domain.</p>
  
  <p>i got the following files back:</p>
  
  <pre><code>root@www:/etc/ssl/certs # ls
  14595113.crt
  COMODOECCExtendedValidationSecureServerCA.crt
  AddTrustExternalCARoot.crt
  COMODOECCAddTrustCA.crt
  domain.tld.bundle.crt
  </code></pre>
  
  <p>From <a href="https://rasmith.me.uk/2014/07/27/So-You-Want-To-Be-Secure/" rel="nofollow">https://rasmith.me.uk/2014/07/27/So-You-Want-To-Be-Secure/</a></p>
  
  <p>The three files stipulated are;</p>
  
  <ul>
  <li>Your server certificate in PEM format.</li>
  <li>Your private key in PEM format.</li>
  <li>A certificate chain file.</li>
  </ul>
  
  <p>When I try to convert my key to PEM format, I get the following error:</p>
  
  <pre><code># openssl rsa -in domain.key -outform PEM -out domain_pem.key
  34379118248:error:0607907F:digital envelope routines:EVP_PKEY_get1_RSA:expecting an rsa key:/usr/src/secure/lib/libcrypto/../../../crypto/openssl/crypto/evp/p_lib.c:288:
  </code></pre>
  
  <p>Google returns this <a href="http://openssl.6102.n7.nabble.com/EVP-PKEY-get1-RSA-expecting-an-rsa-key-td46677.html" rel="nofollow">http://openssl.6102.n7.nabble.com/EVP-PKEY-get1-RSA-expecting-an-rsa-key-td46677.html</a></p>
  
  <p>but no one has answered it.</p>
  
  <p>Any advise on how I can convert the key to PEM format, or if I have missed something in my procedure will be much appreciated.</p>