Problem description
I need to control an arbitrary application on an iOS device, my plan is to inject an executable to the IPA ( where remote control logic is implemented ) and then re-package it.
Since the application should run in a controlled environment ( a specific device ), I plan on using my provisioning profile with my development certificate for re-packaging/signing.
To begin with, I am trying to re-package the 3rd party app w/o Injecting any code, this is done is the following manner:
1. Unzip the existing IPA
2. Copy the provisioning profile to %APP_NAME%.app/embedded.mobileprovisioning
3. export CODESIGN_ALLOCATE="/Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/codesign_allocate"
4. signcode --force --deep -s "%Dev Cert Name%" "%Path/To/APP_NAME%.app"
5. zip the re-signed code back together
The Above is working great for an applications I manually build using Xcode, however, when using IPAs downloaded from the AppStore this doesn't work with the following device log error:
<Debug>: AppleFairplayTextCrypterSession::fairplayOpen() failed, error -42112
Inspecting the 'Mach-O' Executable of the application, I have verified that the "Code Signature" section of the relevant architecture was fully changed ( by the 'signcode' tool ).
Questions
- Why can't I re-package the app I have downloaded from the AppStore while the an app I manually create w/ Xcode is successfully re-packaged/signed?
- How can I re-package/sign an AppStore app using my development certificate & provisioning profile?
- How does FairPaly distinguish between an app I manually produce ( using Xcode ) to an app downloaded from the appstore? what residuals does an appstore app has that a manually made app does not ?