Sample Header Ad - 728x90

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

2 votes
1 answer
3652 views
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?
Asked by ArtemNovikov (121 rep)
Sep 17, 2022, 04:20 PM
Last activity: Jun 2, 2025, 06:07 PM