Last active
July 22, 2018 22:08
-
-
Save fabiogomezdiaz/9c4ba5a29558c406461a9e5b6d4524d2 to your computer and use it in GitHub Desktop.
To be able to decrypt certificate
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
#!/bin/bash | |
# Based on GitHub Issue: https://github.com/fastlane/fastlane/issues/12260 | |
set -o pipefail | |
if [[ -z "$1" ]] || [[ -z "$2" ]] || [[ -z "$3" ]] || [[ -z "$4" ]]; then | |
echo "usage: $0 <MATCH_P12_FILE> <MATCH_CER_FILE> <MATCH_PROVISIONING_PROFILE_FILE> <MATCH_PASSWORD>" | |
exit 1 | |
fi | |
P12=$1 | |
CER=$2 | |
PROVISION=$3 | |
PASSWORD=$4 | |
# decrypt private key | |
echo "Decrypting Private Key \"${P12}\" ..." | |
openssl aes-256-cbc -k ${PASSWORD} -in ${P12} -out key.pem -a -d | |
# decrypt cert | |
echo "Decrypting Certificate \"${CER}\" into \"cert.dem\" ..." | |
openssl aes-256-cbc -k ${PASSWORD} -in ${CER} -out cert.der -a -d | |
# convert cert from der to pem | |
echo "Converting from \"cert.der\" to \"cert.pem\" ..." | |
openssl x509 -inform der -in cert.der -out cert.pem | |
# combine private key + cert into p12 (enter password to secure output p12 file) | |
echo "Combining private key (key.pem) + cert (cert.pem) into CERT.p12 ..." | |
openssl pkcs12 -export -out CERT.p12 -inkey key.pem -in cert.pem | |
# decrypt provisioning profile | |
echo "Decrypting provisioning profile: ${PROVISION}" | |
openssl aes-256-cbc -k ${PASSWORD} -in ${PROVISION} -out $(basename ${PROVISION}) -a -d | |
# Cleanup | |
echo "Cleaning Up" | |
rm cert.der cert.pem key.pem |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment