Created
May 4, 2016 08:04
-
-
Save slabko/5c3210207b2c2d62a61148389fc94800 to your computer and use it in GitHub Desktop.
Change password of a p12 file
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/sh | |
# Usage resing.sh Input.p12 Output.p12 | |
# Use at your own risk | |
echo 'Downloading Apple Root Certificate' | |
curl https://developer.apple.com/certificationauthority/AppleWWDRCA.cer > AppleWWDRCA.cer | |
echo 'Please enter original .p12 password' | |
openssl pkcs12 -in $1 -nocerts -out privateKey.pem -passout pass:qwert | |
echo 'Please enter original .p12 password one more time (sorry about that)' | |
openssl pkcs12 -in $1 -clcerts -nokeys -out publicCert.pem | |
FRIENDLY_NAME=`cat privateKey.pem | grep friendlyName | awk '{print substr($0, 19, 150); exit}'` | |
echo 'Enter new password' | |
openssl pkcs12 -export -out $2 \ | |
-inkey privateKey.pem \ | |
-in publicCert.pem \ | |
-certfile AppleWWDRCA.cer \ | |
-passin pass:qwert \ | |
-name "$FRIENDLY_NAME" | |
rm privateKey.pem publicCert.pem AppleWWDRCA.cer | |
echo "Nicely done!\n" |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment