Mac OS X security export won't accept passphrase
This is just broken, IMO. 'security export' behaves very badly if you try to export private keys and you log in with SSH. Same commands work when you log in from the GUI. Is this on purpose?
Depending on what you need, you might be able to work around it with 'security find-certificates' or 'security export -t certs'. It all works as long as you don't export a private key.
If your passphrase has any odd symbols your shell is swallowing, try using single quotes instead of double to prevent interpolation.
security export -k login.keychain -t all -P 'passphrase'
When I run
security export -t identities
I get the same error message:
security: SecKeychainItemExport: Passphrase is required for import/export.
However, if I specify a format with the -f open (and put the binary output stream into a file), it works:
security export -P testing -f pkcs12 -t identities -o test.p12
yields a file I can work with via openssl
.
It looks to me like security
is just using the wrong error message here, thus making it look like the feature doesn't work. It probably should be saying "You must specify a format to export private keys", or words to that effect.
The actual insight comes from this tweet.