Skip to content

Instantly share code, notes, and snippets.

@larryhou
Last active March 4, 2016 08:23
Show Gist options
  • Save larryhou/47b80e9e8e713c932eaf to your computer and use it in GitHub Desktop.
Save larryhou/47b80e9e8e713c932eaf to your computer and use it in GitHub Desktop.
Dump certificates file from mobile provision file
#!/bin/bash
cd $(dirname ${0})
# file='thenextmoba_dev.mobileprovision'
file='RDMEXP.mobileprovision'
num=$(xmllint --xpath 'count(//array/data)' ${file})
# Add the following function into ~/.bash_profile
function dump-cert()
{
openssl x509 -inform der -in "${1}" -noout -text
}
let i=0
while [ ${i} -lt ${num} ]
do
let n=i+1
xmllint --xpath "//array/data[${n}]/text()" ${file} | base64 --decode -o out.crt
name=$(dump-cert out.crt | grep -i 'Subject:' | awk -F', ' '{print $2}' | awk -F': ' '{print $NF}')
mv -f out.crt "$(echo -e ${name}).crt"
echo -e "${n}\t${name}crt"
let i=n
done
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment