Tuesday, June 12, 2012

How to re-sign an ipa file?

On rare occasions you may be provided with an ipa file (only the ipa file and not the code) that has been signed with a different code signing identity, and you will need to re-sign it with the correct identity before submitting to appstore or for beta testing.

To check the current signature of the ipa file..

First unzip it to get the .app file using,

unzip ".ipa_file_name"

Now check the signature of the .app file using,

codesign -dvvv ".app_file_name"

In the output by reading the value of the Authority attribute you can determine if the app was signed using a developer certificate or a distribution certificate.
Authority=iPhone Distribution: Appleseed Inc.
Authority=iPhone Developer: Appleseed Inc.

Once you have verified that the current signature is incorrect you can proceed to re-sign the ipa file.

Remove old code signature
rm -r "Payload/Application.app/_CodeSignature" "Payload/Application.app/CodeResources"

Replace embedded mobile provisioning profile
cp "MyEnterprise.mobileprovision" "Payload/Application.app/embedded.mobileprovision"

/usr/bin/codesign -f -s "iPhone Distribution: Certificate Name" --resource-rules "Payload/Application.app/ResourceRules.plist" "Payload/Application.app"

zip -qr "Application.resigned.ipa" Payload


No comments:

Post a Comment