I need to programmatically get data (public key) from a certificate that was used to sign the iOS application. Does anyone know whether this is even possible? Is there some API? Looks like there are severals solutions for MacOS, but none of them fits iOS.
Try following steps:
.ipa
). You can simply use Archive Utility for this..app
)embedded.mobileprovision
with the application of your choice, like TextWrangler. You'll find the signing certificate key (or certificates if you used more than one) within the <data>
element inside DeveloperCertificates of the PropertyList
security cms -D -i embedded.mobileprovision
In addition, if you want to extract the public key and save it directly to a file, perform the following in terminal:
Download and install Homebrew if you haven't installed it already:
ruby -e "$(curl -fsSL https://raw.github.com/mxcl/homebrew/go/install)"
Install XMLStarlet or any other tool which helps us parse the contents of the plist:
brew install xmlstarlet
Like before, we use the security cms
command to decode the embedded.mobileprovision profile, but this time we feed it directly to XMLStarlet (the xml
command) to parse the data section of the DeveloperCertificates
element, which contains the public key. We read it with openssl and write it to a file, which we call publickey.pem:
security cms -D -i embedded.mobileprovision | xml sel -t -v "/plist/dict/key[. = 'DeveloperCertificates']/following-sibling::array[1]/data[1]" | awk '{print $1}' | sed '/^$/d' | base64 -D | openssl x509 -inform der > publickey.pem
You'll find the public key in the file publickey.pem
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With