2

I had export .cer file from keychain and using below command try to convert in .pem file but in resulted .pem file missing

-----BEGIN PRIVATE KEY-----

please any one can give another way to do that

command are like

openssl pkcs7 -text -in certfile.cer -print_certs -outform PEM -out certfile.pem
Sagar Vasoya
  • 158
  • 1
  • 12
  • Possible duplicate of [Generate .pem file Used to setup Apple PUSH Notification](https://stackoverflow.com/questions/21250510/generate-pem-file-used-to-setup-apple-push-notification) – Mayur Karmur Dec 25 '18 at 06:49
  • Your Keychain export failed. A CER file in this case is an X509 certificate; not a private key. Perhaps [Apple Stack Exchange](http://apple.stackexchange.com/) would be a better place to ask how to export a certificate or private key from a Keychain. – jww Jan 08 '19 at 06:42

3 Answers3

5

If anyone wants to use command which is recommended for creating pem file, then here is solution on my gist.

  1. openssl x509 -in aps_development.cer -inform der -out PushChatCert.pem
  2. openssl pkcs12 -nocerts -in PushChatKey.p12 -out PushChatKey.pem
  3. cat PushChatCert.pem PushChatKey.pem > ck.pem

First 3 commands will generate pem, but if you want to test then 4th and 5th command will be necessary.
If you got error that about unknown command 'telnet' then install telnet from brew.

Mrugesh Tank
  • 3,495
  • 2
  • 29
  • 59
4

openssl x509 -inform der -in certificate.cer -out certificate.pem

Look no further. This is all that it takes.

ZachHappel
  • 363
  • 2
  • 4
3

Also, I have the same issue when I convert .p12 file into .pem file when I open that .pem file in that missing ----BEGIN PRIVATE KEY-----

So after searching find out solution use this convert .p12 to .pem

AskNilesh
  • 67,701
  • 16
  • 123
  • 163
Ruchi Makadia
  • 1,005
  • 1
  • 7
  • 20