How to install a developer certificate / private key and preparation profile for iOS development through the command line?

I am setting up an automatic build server for an iOS application project. I have done most of this. Now this is the last round. Security.

A developer certificate / private key and provisioning profile can be easily installed in Keychain with a graphical interface. But I want to do this through the command line to automate even the configuration process. Export / import of certificates, private keys, preparation profiles via the command line.

Any recommendations would be greatly appreciated.

+35
command-line ios sdk keychain
Dec 06 '10 at 17:22
source share
2 answers

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

security team. I am reading a manual page. I will update this answer later after the trial version :)

- (edit) -

First, we must provide "Always allow" access to certificates / keys in Keychain manually once. I do not know how to do this without a GUI.

And run the security unlock-keychain command before running the build tool for each session. I used SSH, so I had to execute it once for each login session.

+14
Dec 06 2018-10-06
source share

Always allow the GUI to run, because the code did not receive acl to access your private key. try the following:

 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 the code name to have access to the keys that you import in Certificate.p12.

+45
Mar 17 '11 at 10:18
source share