Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Add/import certificate with password via command line Mac OS X

I'm trying to import a .pfx certificate via command line. This certificate is secured by a password. Is there a way to do this in terminal? I'm running OS X 10.8.

When I use this command I get the default pop-up asking for the password:

security import certificate.pfx -k ~/Library/Keychains/login.keychain

When I use this command:

security import certificate.pfx -k ~/Library/Keychains/login.keychain -P password

I get this error:

SecKeychainItemImport: MAC verification failed during PKCS12 import (wrong password?)

I'm sure the password is correct because it works if I enter it manually.

Thanks!

like image 413
Matter Avatar asked May 01 '14 15:05

Matter


People also ask

Where are passwords and certificates stored in a Mac?

Keychain Access lets you view the keys, certificates, passwords, account information, notes, or other information stored in a keychain. In the Keychain Access app on your Mac, if you don't see a list of keychains, choose Window > Keychain Viewer or press Command-1.


1 Answers

Got it!

The password starts with a dollar and I didn't escape it with a \.

So let's say the password is $tup1dP@ssw0rd the command has to be:

security import certificate.pfx -k ~/Library/Keychains/login.keychain -P \$tup1dP@ssw0rd
like image 102
Matter Avatar answered Jan 04 '23 08:01

Matter