Skip to content

Instantly share code, notes, and snippets.

@command-tab
Created April 12, 2012 20:17

Revisions

  1. command-tab created this gist Apr 12, 2012.
    14 changes: 14 additions & 0 deletions gistfile1.sh
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,14 @@
    # 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