macOS: Import .p12 certificate into the keychain via command line

Viewed 31

I'm trying to import .p12 certificate into the keychain on my mac via bash script. So far, I've been trying:

  1. sudo security import command. It returns that import was successful but, in fact, it never gets imported into any keychain.
  2. sudo security add-certificates -k /Library/Keychains/System.keychain certificate.p12 it throws the following error:

Password: SecCertificateCreateFromData: Unknown format in import.

The only thing that worked for me was the .cer format via this command: sudo security add-certificates -k /Library/Keychains/System.keychain certificate.cer. It does import the certificate into the keychain and I can see it in the keychain access.

But I only have .p12 certificates. Could anyone help me with that one, please?

0 Answers
Related