Warm tip: This article is reproduced from serverfault.com, please click

install .p12 or .cer in console macos

发布于 2011-09-20 13:18:58

I've try install .p12 cert to my macos use command line.

I can install .cer

sudo certtool I Certificates.p12 d

but it doesn't work on computers where this cert is not generated. As I see i should use .p12 But how can I install .p12 ?

I've tried to use

security add-certificates "/Users/$NAME/Library/Keychains/login.keychain" "$CERT_PATH"

But result same as previous command. Can't install .p12

Please help.

Thanks,

Questioner
Sergey Kopanev
Viewed
0
Stuart Ervine 2011-12-15 18:35:29

It looks like you can do this using the import command. I've managed to do the following:

security create-keychain -p password bobbins.keychain
security add-certificates ./MyCertificate.cer

security unlock-keychain -p password bobbins.keychain
security import ./MyPrivateKey.p12 -k bobbins.keychain -P privateKeyPassword

I found I had to unlock the keychain, otherwise it prompted for the keychain password.

Hope this helps.