0
我尝试使用以下命令导入pkcs#12
证书到OS X钥匙串:运行安全导入命令具有不同的行为比命令行
security import filename -k ~/Library/Keychains/login.keychain -P password -f pkcs12
在Python中我用subprocess
这样的:
if os.path.isfile(_file) and platform.system() == 'Darwin':
keychain = os.path.expanduser('~/Library/Keychains/login.keychain')
command_line = 'security import {} -k {} -P {} -f pkcs12'.format(_file, keychain, password)
logger.info('Importing {} into OS X KeyChain.'.format(_file))
return subprocess.call(shlex.split(command_line))
不过,我收到此错误信息:
security: SecKeychainItemImport: One or more parameters passed to a function were not valid.
我甚至尝试过使用shell=True
,但后来我得到了security
的使用情况,好像我通过了一些错误的参数。
Usage: security [-h] [-i] [-l] [-p prompt] [-q] [-v] [command] [opt ...]
...
...
但是,按预期的命令行,命令的工作运行时:
security import <filename> -k <home>/Library/Keychains/login.keychain -P DTWLDHPYNBWBJB3 -f pkcs12
1 identity imported.
1 certificate imported.
任何想法?从非交互式控制台运行security
时是否有限制?
任何python库实现一样吗?
Regards