Last active
March 4, 2016 08:23
-
-
Save larryhou/47b80e9e8e713c932eaf to your computer and use it in GitHub Desktop.
Dump certificates file from mobile provision file
This file contains 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
#!/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