Current location - Quotes Website - Signature design - How to re-sign ipa document
How to re-sign ipa document
prepare

Do some preparatory work before re-signing.

1. First, download and install Xcode, which contains a codesign_allocate program. At the time of installation, there will be an additional codesign program in /usr/bin to sign ipa packages.

2. Certificate file, private key file and supply configuration file of enterprise certificate. Note that the enterprise certificate must be an iOS distribution type, not an iOS development.

Re-signature step

1. Unzip ipa

Unzip ipa to get payload/[application name]. Tie, and then open the tie.

2. Delete the old ipa signature information

Delete the _CodeSignature folder in the bundle, that is, delete the signature information of ipa before.

Step 3 Replace the certificate

Delete the old configuration file in the bundle and replace it with the configuration file of our own enterprise certificate.

Please note that our enterprise certificate in ipa package should be renamed as embedded.mobileprovision.

4. Modify the bundled content

At this point, we can modify the contents in the bundle at will, such as adding a dynamic library and deleting a picture.

Note: If you want to add a dynamic library to the bundle, you must first compress it into a zip file, then unzip it into the Documents directory when the program starts, and then dlopen it, otherwise the dynamic library file will get stuck when the program starts.

re-sign

After modifying the contents of the package, you need to re-sign it through the /usr/bin/codesign program. The command is as follows:

/usr/bin/code sign-f-s " iPhone Distribution:your company name "-resource-rules Payload/MYAPP.app/ResourceRules.plist Payload/myapp . app

Among them, iPhone distribution can be obtained from keychain access, which is the name of enterprise certificate, such as the following "iPhone distribution: xxxxxxxx":

Examples of specific commands:

codesign-f-s " iPhone Developer:xxxxxxxxxxxxx "-resource-rules Payload/NdCP _ Game _ demo . app/resource rules . plist Payload/NdCP _ Game _ demo . app

The meaning of this command is: use the certificate identified by "iPhone Developer:xxxxxxxxxxxxx" in keychain to sign according to the rules in Payload/NdCP _ Game _ demo. app/ResourceRules.plist. If the signature already exists in ipa package, it will be replaced, and the _CodeSignature directory generated by this process will be stored in Payload/NDCP _ Game _ demo.app.

After the command is executed, a new _CodeSignature directory will be generated in the bundle, which contains new signature information.

Repackage in ipa

After the above work is completed, a new ipa can be generated and released. Examples of commands are as follows:

Zip -r retest. ipa payload

# Please note that the payload cannot be followed by "/"

release

After packaging and publishing test, it is concluded that the re-signed ipa file can be successfully installed on non-jailbreak devices and jailbreak devices after modifying the content of ipa package and the signature in it. Note that it is installed through the website with SSL certificate and Apple system (internal distribution program), not through third-party tools such as PP assistant.