Skip to content

Instantly share code, notes, and snippets.

@LucaBongiorni
Forked from command-tab/gist:2370710
Created July 21, 2014 12:33
Show Gist options
  • Save LucaBongiorni/4fc2b5608da8ef12d4f9 to your computer and use it in GitHub Desktop.
Save LucaBongiorni/4fc2b5608da8ef12d4f9 to your computer and use it in GitHub Desktop.
# Parse a provisioning profile
# Extract the first DeveloperCertificates <data> entry
# Remove any leading whitespace
# Remove any blank lines
# Base64 decode the blob
# Parse the .cer with OpenSSL
# Extract the first line, which is the certificate subject (the rest is the cert blob)
# End up with a string like: subject= /UID=AABBCCDDEE/CN=iPhone Developer: First Last (FFGGHHIIJJ)/C=US
# Note: Uses xmlstarlet to parse the plist, but you could probably use PlistBuddy or grep, too
security cms -D -i "/path/to/some.mobileprovision" | \
xml sel -t -v "/plist/dict/key[. = 'DeveloperCertificates']/following-sibling::array[1]/data[1]" | \
awk '{print $1}' | sed '/^$/d' | base64 -D | openssl x509 -subject -inform der | head -n 1
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment