title: Generate PEM from private key, Apple CER
body: <p>I am trying to create a .pem file for the Apple Push Notification service, but can't find an easy way to generate it.</p>
  
  <p>I do not have access to an Apple computer, so Apple's instructions are useless. Using Windows 10.</p>
  
  <p>What I did:</p>
  
  <ol>
  <li>Made a CSR + private key through a generator (specifically, WHM). They are in plain text format</li>
  <li>Created a CSR file with the .certSigningRequest extension by copy&amp;pasting the request into the file</li>
  <li>Uploaded the CSR to the Apple dev center and got back a certificate, in the <code>CER</code> format, courtesy of Apple</li>
  </ol>
  
  <p>So in the end, I have the private key in plain text format and the cert in CER format.</p>
  
  <p>However, I read that CER is supposed to just be a CRT with a different extension; that, however, does not appear to be the case, and I don't know how to extract the plain-text certificate from the CER file I received in order to make a PEM. Also I'm not quite sure on how to generate a p12 file from the stuff I have (this is listed as one of the possible easy ways to make a PEM).</p>
  
  <p>The question is, either: is it possible to extract the plain-text cert from the CER file? Or alternatively, convert it to PEM along with the private key somehow? (I have OpenSSL)</p>
  
  <p><strong>Update:</strong> I was able to extract the text part of the CER, turns out Apple CERs are in DER format, so it's possible to use:</p>
  
  <pre><code>openssl x509 -in cert.cer -inform DER -out cert.crt
  </code></pre>
  
  <p>There is still a problem however: a PEM also contains some kind of data in between the key and the certificate (bag attributes, key attributes), not sure how to generate it. Investigating now but an answer would be very helpful!</p>