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

ぐ巨炮叔叔 提交于 2019-12-18 15:26:48

问题


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!


回答1:


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


来源:https://stackoverflow.com/questions/23410890/add-import-certificate-with-password-via-command-line-mac-os-x

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!