如何通过命令行为 iOS 开发安装开发者证书/私钥和配置文件?

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/4369119/
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

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-08-30 18:14:22  来源:igfitidea点击:

How to install developer certificate/private key and provisioning profile for iOS development via command line?

command-lineiossdkkeychain

提问by Eonil

I'm configuring automated build server for iOS application project. I've done most of it. Now, it's the final round. The security.

我正在为 iOS 应用程序项目配置自动构建服务器。我已经完成了大部分。现在,是最后一轮了。安全。

Developer certificate/private key and provisioning profile can be easily installed into Keychain with GUI. But I want to do this via command line to automate even the configuring process. Exporting/importing certificates, private keys, provisioning profiles via command line.

开发人员证书/私钥和配置文件可以通过 GUI 轻松安装到钥匙串中。但我想通过命令行来做到这一点,甚至可以自动化配置过程。通过命令行导出/导入证书、私钥、配置文件。

Any recommendations will be very appreciated.

任何建议将不胜感激。

采纳答案by Eonil

I found hints from: http://lists.apple.com/archives/apple-cdsa/2010/Mar/msg00021.html

我从以下位置找到了提示:http: //lists.apple.com/archives/apple-cdsa/2010/Mar/msg00021.html

The command is security. I'm reading manual page. I'll update this answer later after trial :)

命令是security. 我正在阅读手册页。我稍后会在试用后更新此答案:)

--(edit)--

- (编辑) -

First, we have to give 'Always Allow' access to the certificates/keys in the Keychain manually once. I don't know how to do this without GUI.

首先,我们必须手动授予“始终允许”访问钥匙串中的证书/密钥一次。我不知道如何在没有 GUI 的情况下做到这一点。

And run the command security unlock-keychainbefore running build tool for every session. I've used SSH, so I had to execute it once for every login sessions.

security unlock-keychain在为每个会话运行构建工具之前运行该命令。我使用过 SSH,所以我必须为每个登录会话执行一次。

回答by ablarg

The always allow GUI is being triggered because codesign hasn't been given an acl to access your private key. try this:

始终允许 GUI 被触发,因为 codesign 尚未获得访问您的私钥的 acl。尝试这个:

security unlock-keychain -p <my keychain password>
security import Certificate.p12 -k ~/Library/Keychains/login.keychain -P password -T /usr/bin/codesign

The -T flag tells security to allow codesign to have access to the keys you are importing in Certificate.p12.

-T 标志告诉安全性允许 codesign 访问您在 Certificate.p12 中导入的密钥。