Pages

Wednesday, January 16, 2013

iOS: Application Signing using iResign (for MobileIron Deployment)

This is a fairly simple blog that just takes you through the process of signing an application with a corporate distribution certificate so that it can be distributed internally to an organisation (using, for example, MobileIron).

In order to get started you need to have installed Xcode (via the Apple App Store for the Mac) and then  download iResign from it's github repository;
iResign on github
Once you've downloaded the zip file if you double-click it it will extract into a new folder, you can then open that;
iResign Xcode Project Download Directory
Double-click on the top file (iResign.xcodeproj), this will then open in Xcode.

You don't need to worry about the contents of the project, just run it and the application will appear;

iReSign Application
The top browse button allows you to select the downloaded application you with to re-sign.

The second box is to identify the location of your .mobileprovision file (see below for instructions on how to get this and the certificates).

The third box allows you to override the specified company name, we've never needed to use this! Finally is the name of the the Certificate from your Keychain.

Once you've got all these click "ReSign!" and as if by magic you should have a new file in the same directory as the original file except with -resigned appended to it's name.

"Signing failed" Error Message
If you see this error message;

iResign: Signing failed error message

Then the problem is that you are missing the Command Line Tools in Xcode. If you start Xcode, go to Preferences, then Downloads and check you have "Command Line Tools" installed;

Xcode: Preferences > Downloads > Command Line Tools
If you install the tools (usually takes a few minutes) then you should just be able to switch back to iResign and click "ReSign!" again and this time it will work.

Downloading Provisioning Profiles and Certificates

You can download this by logging into your developer account (https://developer.apple.com);

Apple Developer Website
Click on the "iOS Dev Center". If you aren't logged in log in on the next page. At the top-right of the next page there are three options under the heading "iOS Developer Program";

iOS Developer Program
Select the top option, "iOS Provisioning Portal", on the left side of the next page are a number of options;

Welcome to the IOS Provisioning Portal
To get your certificate (to install in your keychain) click on the "Certificates" option and then click on the "Distribution" tab;

Current Distribution Certificate
To download the certificate click on the "Download" link on the right side. And a .cer file will download, when it's finished (should take a few seconds) click on it and you'll be prompted by KeyChain to add your certificate;

Keychain Access: Add Certificates Dialog
If you click on "View Certificates" you get more detail on the certificate you're installed;

New Certificate Details
The bit I've covered up at the top is the name of the certificate, this is the bit you need to copy exactly into iReSign (Certificate Name from keychain).

Return to the previous dialog and click "Add".

Now you've got your distribution certificate you need to get your provisioning profile. Click on "Provisioning" on the left-hand side;

Provisioning Profiles
Make sure you've clicked on "Distribution" (top tab) and then download the provisioning profile you wish to use. This is the ".mobileprovision" file you need to enter into iReSign.

And you're done, you now have everything you need to resign an application for deployment within an enterprise!

1 comment:

GKS said...

Thanks for sharing. The command line tools error was stumping me.