Setting up receipt validation for Mac OS X application can be a tedious task, especially with all the steps to follow in order to have a proper test environnement. Of course, by using Receigen, the code writing part is easy as pie, but most of the issues occur during the testing.

I have written a shell script that dumps all the information regarding the hardware, the application bundle and the receipt. With one command, you are able to see information like the primary MAC address, the bundle identifier and version and the essential values of the receipt.

So, if you encounter a problem during the testing of the receipt validation, running this script will be give you all the information needed to diagnose the problem.

To use it (assumer the script is located under the current directory):

$> ./receigen_dump.sh /Applications/<Your App>.app

Here is an example of the output for the Xcode.app:

===========================
===== Receigen Dumper =====
===========================

----- BEGIN HARDWARE INFORMATION -----
System Name         : Darwin cupertino 11.4.0 Darwin Kernel Version 11.4.0: Mon Apr  9 19:32:15 PDT 2012; root:xnu-1699.26.8~1/RELEASE_X86_64 x86_64
Primary MAC Address : c4:2c:03:c4:2c:03
----- END HARDWARE INFORMATION -----

----- BEGIN APPLICATION INFORMATION -----
Application Bundle     : /Applications/Xcode.app/
Application Name       : Xcode.app
Application Identifier : com.apple.dt.Xcode
Application Version    : 4.3.2

Signature check
---------------
/Applications/Xcode.app/: valid on disk
/Applications/Xcode.app/: satisfies its Designated Requirement

Signature information
---------------------
Executable=/Applications/Xcode.app/Contents/MacOS/Xcode
Identifier=com.apple.dt.Xcode
Format=bundle with Mach-O thin (x86_64)
CodeDirectory v=20100 size=187 flags=0x200(kill) hashes=3+3 location=embedded
Hash type=sha1 size=20
CDHash=f1cd6c670213af6d6fa7374f04de6a68fdb5e614
Signature size=4169
Authority=Apple Mac OS Application Signing
Authority=Apple Worldwide Developer Relations Certification Authority
Authority=Apple Root CA
Info.plist entries=30
Sealed Resources rules=14 files=45
Internal requirements count=2 size=344

Signed files
------------
Executable=/Applications/Xcode.app/Contents/MacOS/Xcode
/Applications/Xcode.app/Contents/MacOS/Xcode
/Applications/Xcode.app/Contents/_CodeSignature/CodeResources

Designated requirements
-----------------------
Executable=/Applications/Xcode.app/Contents/MacOS/Xcode
designated => (anchor apple generic and certificate leaf[field.1.2.840.113635.100.6.1.9] /* exists */ or anchor apple generic and certificate 1[field.2.5.29.37] /* exists */ and certificate 1[subject.CN] = "Apple Code Signing Certification Authority" and certificate leaf[field.2.5.29.37] /* exists */ and certificate leaf[subject.CN] = "Software Signing") and identifier "com.apple.dt.Xcode"
library => identifier "libSystem.B.dylib" and anchor apple

Entitlements
------------
Executable=/Applications/Xcode.app/Contents/MacOS/Xcode

----- END APPLICATION INFORMATION -----

----- BEGIN RECEIPT INFORMATION -----
Receipt identifier : com.apple.dt.Xcode
Receipt version    : 4.3.2
Receipt opaque     : 000000000000
Receipt SHA-1      : 4747474747474747474747474747474747474747

subject=/CN=Mac App Store Receipt Signing/OU=Apple Worldwide Developer Relations/O=Apple Inc./C=US
issuer=/C=US/O=Apple Inc./OU=Apple Worldwide Developer Relations/CN=Apple Worldwide Developer Relations Certification Authority

subject=/C=US/O=Apple Inc./OU=Apple Worldwide Developer Relations/CN=Apple Worldwide Developer Relations Certification Authority
issuer=/C=US/O=Apple Inc./OU=Apple Certification Authority/CN=Apple Root CA

subject=/C=US/O=Apple Inc./OU=Apple Certification Authority/CN=Apple Root CA
issuer=/C=US/O=Apple Inc./OU=Apple Certification Authority/CN=Apple Root CA

----- END RECEIPT INFORMATION -----

The link to the shell script.