在控制台 macos 中安装 .p12 或 .cer
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/7485806/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
install .p12 or .cer in console macos
提问by Sergey Kopanev
I've try install .p12 cert to my macos use command line.
我已经尝试将 .p12 证书安装到我的 macos 使用命令行。
I can install .cer
我可以安装 .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 ?
但它不适用于未生成此证书的计算机。正如我所见,我应该使用 .p12 但是我该如何安装 .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
但结果与之前的命令相同。无法安装 .p12
Please help.
请帮忙。
Thanks,
谢谢,
回答by Stuart Ervine
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.
希望这可以帮助。
回答by Marian
This will import the bundle to the default keychain:
这会将捆绑包导入默认钥匙串:
security import ./bundle.p12 -P secretPassword
secretPassword
is the p12 file encryption password.
secretPassword
是p12文件加密密码。
While the answer by Stuart should work, it is not required to create another keychain first.
虽然 Stuart 的答案应该有效,但不需要先创建另一个钥匙串。