IT

Extract a public key from p12 file

하마연구소장 2019. 2. 6. 12:10
728x90
반응형

http://stackoverflow.com/a/16847082

I remembered vaguely being able to do this with openssl on .pem files, so that's the direction I headed.

  • In Keychain Access, export the private key as eg private.p12. Apply a password, or not.
  • Convert it to .pem: openssl pkcs12 -in private.p12 -out private.pem. Enter password from previous step. You're forced to apply a password to the .pem.
  • Extract the public portion: openssl rsa -in private.pem -pubout > public.pem. Enter password from previous step.
  • Import into Keychain Access: security import public.pem -k login.keychain. If you don't specify a keychain, the import appears to complete but I couldn't find where the item was put.
  • In Keychain Access, look in the login keychain for "Imported Public Key". Rename it and move to the desired location.
  • Clean up after yourself, especially those .p12 and .pem private keys with no or poor passwords.


반응형