Showing posts with label codesign. Show all posts
Showing posts with label codesign. Show all posts

Tuesday, 27 September 2016

Codesign guide: Changes for MacOS Sierra (10.12)

If you are facing any problems on MacOS Sierra (10.12) related to codesigning, it might be one of the cases mentioned below. Check out the common problems and how to fix them to be fully compliant with MacOS Sierra-

Problem: Application launched from dmg is not working properly after downloading dmg from web.

Solution: Starting with MacOS Sierra, running a newly-downloaded app from a disk image, archive, or the Downloads directory will cause Gatekeeper to isolate that app at an unspecified read-only location in the filesystem. This will prevent the app from accessing code or content using relative paths.
Sign your disk images so that Gatekeeper can verify it when it is mounted for the first time.

----------------------------------------------------------------------------------------------------------------------

Problem: How can I sign a dmg file?

Solution: Disk images can be signed using the codesign tool on MacOS 10.11.5 and later. This allows the entire disk image to be validated by Gatekeeper the first time it is mounted.
Gatekeeper will validate the contents of the disk image as well.
Disk images should only be signed with your Developer ID Application identity.

----------------------------------------------------------------------------------------------------------------------

Problem: How can I verify the signature of my dmg file?

Solution: On MacOS Sierra and later, spctl can be used to assess a disk image's signature, like this:

$ spctl -a -t open --context context:primary-signature -v MyImage.dmg
/Users/me/Downloads/MyImage.dmg: accepted
source=Developer ID

----------------------------------------------------------------------------------------------------------------------

Problem: Can I sign ISO images?

Solution: No, there is no provision for signing these. Preferably, do not ship apps using ISO images.

----------------------------------------------------------------------------------------------------------------------

Problem: Is it possible to resign a dmg that is already signed?

Solution: A disk image signed on OS X 10.11.5 or 10.11.6 may not be able to be re-signed. In this situation, the operation will appear to succeed, but the signature will be invalid. If you encounter this condition, sign a new (unsigned) copy of the image on MacOS Sierra or later.

----------------------------------------------------------------------------------------------------------------------

Problem: Does Gatekeeper verify my app everytime it is launched?

Solution: On MacOS Sierra and later, Gatekeeper will check your app every time it's launched if it is run from the location where it was downloaded. If it is copied to some other directory (like /Applications), then the checks are not repeated again.

----------------------------------------------------------------------------------------------------------------------

References/Useful links:
https://developer.apple.com/library/prerelease/content/technotes/tn2206/_index.html
https://macinstallers.blogspot.in/2014/08/codesign-mavericks-yosemite-commands.html



Friday, 29 August 2014

Codesign on Mavericks/Yosemite: Some useful commands

Recently, Apple announced that from 10.9.5 and 10.10 onwards, the apps signed in OSX Mountain Lion and below will not be able to pass the Gatekeeper. Those signatures (v1) will be considered deprecated and you must sign your apps in 10.9 or above to have latest signature (v2).
At this point of time, it is unclear if Apple is really going to block the apps with v1 signatures. We can’t be sure until we have a GM build for OSX Yosemite. Anyway, it is better to start signing on 10.9 straightaway so that our apps are compliant to the changes done by Apple.
Following are some commands that may be useful:
Verify if any app will be accepted by Gatekeeper on 10.9.5 (OSX Mavericks) /10.10 (OSX Yosemite) or above.
vikrams-macbook-pro:~ admin$ spctl -a -t exec -vv Foo.app
Foo.app: rejected
source=obsolete resource envelope

vikrams-macbook-pro:~ admin$ spctl -a -t exec -vv Foo.app
Foo.app: accepted
source=Developer ID
origin=Developer ID Application: My Company

Sign an app:
codesign  --sign  “Developer ID Application: My Company”  Foo.app

Resign an already signed app (Use –f flag):
codesign  --force --sign  “Developer ID Application: My Company”  Foo.app 

Check the version of the signature. See the line starting with "Sealed Resources". There, version=2 indicates that this app has the new signature type as suggested by Apple:
vikrams-macbook-pro:~ admin$ codesign -dvvv Foo.app 
Executable=Foo.app/Contents/MacOS/Foo
Identifier=com.vikrams.testapp
Format=bundle with Mach-O thin (x86_64)
CodeDirectory v=20200 size=42914 flags=0x0(none) hashes=2138+3 location=embedded
Hash type=sha1 size=20
CDHash=XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX
Signature size=7589
Authority=Developer ID Application: My Company
Authority=Developer ID Certification Authority
Authority=Apple Root CA
Timestamp=23-Aug-2014 4:32:13 pm
Info.plist entries=17
TeamIdentifier=31ACEW5CBX
Sealed Resources version=2 rules=12 files=137
Internal requirements count=1 size=192
You can find more options for "codesign" command at its man page.