Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to sign DMG and installer for OSX

I've been fighting with this for quite some time and would be extremely grateful if anyone could help me understand what's happening here.

I have an install4j project that creates installer packages for Windows and OSX. I have a regular signing cert for Windows and this works without issue. I have an Apple developer certificate as well. I've exported the private key from my keychain to a p12 file. I've tested the resulting p12 file to make sure it works with the keystore password. The certificate is definitely valid, since I just created it (again) today. And, when I run the installer build via Maven, it even looks as though everything is going fine:

[INFO] Compressed media file 'Mac OS X Single Bundle':
[INFO]   Compressing files
[INFO]   Generating VM options file vmoptions.txt.
[INFO]   Signing installer
[INFO]   Signing DMG
[INFO]   Moving media files to media directory /Users/....
[INFO]   The name of the media file is my-app_macos_1_1_1.dmg.
[INFO]   The size of the media file is 4.8 MB

Which seems good, except that the installer and dmg AREN'T signed, or at least not in a way that's useful:

$ spctl -a -v target/media/my-app_macos_1_1_1.dmg
target/media/my-app_macos_1_1_1.dmg: CSSMERR_TP_CERT_EXPIRED
$ spctl -a -v /Volumes/my-app/My\ Application\ Installer.app
/Volumes/my-app/My Application Installer.app: CSSMERR_TP_CERT_EXPIRED

The cert is NOT expired:

Alias name: mac developer: me myself (my company, inc.)
Creation date: Mar 6, 2017
Entry type: PrivateKeyEntry
Certificate chain length: 1
Certificate[1]:
Owner: C=US, O="Radiologics, Inc.", OU=K865L34KBQ, CN=Mac Developer: Me Myself (XXXX), UID=YYYY
Issuer: CN=Apple Worldwide Developer Relations Certification Authority, OU=Apple Worldwide Developer Relations, O=Apple Inc., C=US
Serial number: 30544da25ea67233
Valid from: Mon Mar 06 14:46:17 CST 2017 until: Tue Mar 06 14:46:17 CST 2018

But whether I build the dmg/installer directly from install4j or through the Maven plugin, the result is not valid. I always get something similar to this:

$ codesign -dvvv target/media/my-app_macos_1_1_0.dmg
Executable=.../target/media/my-app_macos_1_1_0.dmg
Identifier=my-app_macos_1_1_0
Format=disk image
CodeDirectory v=20100 size=173 flags=0x0(none) hashes=1+2 location=embedded
Hash type=sha256 size=32
CandidateCDHash sha256=XXXXXX
Hash choices=sha256
CDHash=XXXXX
Signature size=8641
Authority=(unavailable)
Info.plist=not bound
TeamIdentifier=not set
Sealed Resources=none
Internal requirements count=1 size=36

In order for us to be able to distribute this app, we really need to get this to work, but I've spent literally days on this without making any progress at all. If anyone could shed any light on what's going on here, I'd greatly appreciate it.

like image 961
Spanky Quigman Avatar asked Mar 06 '17 22:03

Spanky Quigman


1 Answers

There are two different kinds of certificates for distributing apps outside of the Mac App Store.

An application certificate and an installer cetificate.

Check your certs (which you can do via the "My Certificates" in the Keychain Access app hiding in /Application/Utilities) to make sure you're using an installer certificate (on my machine the name of it is "Developer ID Installer: Michael Dautermann". This is separate from the "Developer ID Application" certificate you use to codesign apps.

More information can be seen here.

As for DMG's, my original answer would have been "can't do that", but actually as of MacOS 10.11.5 you CAN sign dmg files. More information can be seen in the "Signing Disk Images" section of the "macOS code signing in depth" reference guide. You'd use your Developer ID Application certificate.

like image 125
Michael Dautermann Avatar answered Nov 11 '22 20:11

Michael Dautermann