Created
April 12, 2012 20:17
-
-
Save command-tab/2370710 to your computer and use it in GitHub Desktop.
Extract Certificate Subject from a Provisioning Profile
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# 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 |
ikrabbe
commented
May 22, 2015
Hrm, neither script works for me.
First says:
unable to load certificate
18494:error:0D07207B:asn1 encoding routines:ASN1_get_object:header too long:/SourceCache/OpenSSL098/OpenSSL098-52.40.1/src/crypto/asn1/asn1_lib.c:153:
Second says:
unknown option -
usage: x509 args
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment