Skip to content

Instantly share code, notes, and snippets.

@jonahb
Created May 17, 2014 00:41
Show Gist options
  • Save jonahb/7f247671efeada4fcf01 to your computer and use it in GitHub Desktop.
Save jonahb/7f247671efeada4fcf01 to your computer and use it in GitHub Desktop.
Command-line iOS code signing
# Generate the key pair
openssl genrsa -out jonah.key 2048
# Generate the certificate signing request (CSR). Apple ignores the subject, so we leave it blank:
openssl req -new -subj / -key jonah.key -out jonah.csr
# Now submit the CSR to the Apple Developer site. It will give you a certificate in DER format. We need to bundle this certificate with the key pair before we can add it to the keychain where Xcode can access it. Assume the certificate has been named jonah.cer. First convert it from DER to PEM:
openssl x509 -inform der -in jonah.cer -out jonah.pem
# Then package the key pair and certificate into a single PKCS #12 file. You’ll have to type an “export password.”
openssl pkcs12 -export -inkey jonah.key -in jonah.pem -out jonah.p12
# Finally, launch Keychain Access and import the PKCS #12 file with File > Import Items. Keychain Access will prompt you for the password you chose in the last step. If you’re really a command-line die-hard, you can import like this:
security import jonah.p12 -k "/Users/jonah/Library/Keychains/login.keychain"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment