{"id":471,"date":"2014-10-02T01:56:07","date_gmt":"2014-10-02T08:56:07","guid":{"rendered":"http:\/\/porkrind.org\/missives\/?p=471"},"modified":"2014-10-03T13:57:10","modified_gmt":"2014-10-03T20:57:10","slug":"mac-os-x-codesigning-woes","status":"publish","type":"post","link":"https:\/\/porkrind.org\/missives\/mac-os-x-codesigning-woes\/","title":{"rendered":"Mac OS X codesigning woes"},"content":{"rendered":"<p>I just discovered this wonderful bug. Apparently &#8220;<tt>hdiutil makehybrid<\/tt>&#8221; is stripping code signatures in some cases.<\/p>\n<p>I first verify the code signature on an App (<a href=\"http:\/\/emacsformacosx.com\/\">a build of Emacs<\/a>, in this case)\u2014there are no errors:<\/p>\n<pre>$ codesign --verify _dmg-build\/Emacs.app\/\r\n$<\/pre>\n<p>I then use &#8220;<tt>hdiutil makehybrid<\/tt>&#8221; to create a disk image out of the directory.<\/p>\n<pre>$ hdiutil makehybrid -hfs -hfs-volume-name \"Emacs Test\" -hfs-openfolder _dmg-build _dmg-build -o \/tmp\/tmp.dmg<\/pre>\n<p>I then mount the created image and run try to verify the signature again\u2014but this time it fails!<\/p>\n<pre>$ open \/tmp\/tmp.dmg\r\n$ codesign --verify \/Volumes\/Emacs\\ Test\/Emacs.app\/\r\n\/Volumes\/Emacs Test\/Emacs.app\/: code object is not signed at all\r\nIn subcomponent: \/Volumes\/Emacs Test\/Emacs.app\/Contents\/MacOS\/bin-i386-10_5\/grep-changelog<\/pre>\n<p>Investigating further, I use &#8220;<tt>xattr<\/tt>&#8221; to list the extended attributes on the &#8220;<tt>grep-changelog<\/tt>&#8221; file. First, the good file:<\/p>\n<pre>$ xattr _dmg-build\/Emacs.app\/Contents\/MacOS\/bin-i386-10_5\/grep-changelog\r\ncom.apple.cs.CodeDirectory\r\ncom.apple.cs.CodeRequirements\r\ncom.apple.cs.CodeSignature<\/pre>\n<p>And now the bad file:<\/p>\n<pre>$ xattr \/Volumes\/Test\\ Emacs\/Emacs.app\/Contents\/MacOS\/bin-i386-10_5\/grep-changelog\r\ncom.apple.FinderInfo<\/pre>\n<p>Yup, all the code signature stuff is completely gone! (The &#8220;<tt>FinderInfo<\/tt>&#8221; stuff is OK, it&#8217;s just there as a side effect of mounting the disk image).<\/p>\n<p>I&#8217;m not exactly sure how to fix this. Apple recently changed code signing requirements so that 10.9.5 now requires deep signatures (way to change something fundamental in a point release, guys). Also the only thing that correctly makes the deep signatures is Xcode 6 which was released only about 1 week before 10.9.5 was released (way to give advanced warning, guys).<\/p>\n<p><strong>2014-10-03 Update:<\/strong><\/p>\n<p>I filed a bug with Apple and they suggested I use &#8220;<tt>hdiutil create -srcfolder<\/tt>&#8221; instead of &#8220;<tt>makehybrid<\/tt>&#8220;. This does copy the extended attributes correctly. I had originally not used &#8220;<tt>create<\/tt>&#8221; for two reasons: It didn&#8217;t have the &#8220;<tt>-hfs-openfolder<\/tt>&#8221; option and the man page claims that only &#8220;<tt>makehybrid<\/tt>&#8221; makes optimally small filesystems. Turns out that &#8220;<tt>create -srcfolder<\/tt>&#8221; automatically does the same thing as &#8220;<tt>makehybrid -hfs-openfolder<\/tt>&#8221; (though it is not documented in the man page) and in practice the resulting <tt>.dmg<\/tt>s are just as small or smaller. Problem solved!<\/p>\n","protected":false},"excerpt":{"rendered":"<p>I just discovered this wonderful bug. Apparently &#8220;hdiutil makehybrid&#8221; is stripping code signatures in some cases. I first verify the code signature on an App (a build of Emacs, in this case)\u2014there are no errors: $ codesign &#8211;verify _dmg-build\/Emacs.app\/ $ I then use &#8220;hdiutil makehybrid&#8221; to create a disk image out of the directory. $ &hellip; <a href=\"https:\/\/porkrind.org\/missives\/mac-os-x-codesigning-woes\/\" class=\"more-link\">Continue reading <span class=\"screen-reader-text\">Mac OS X codesigning woes<\/span><\/a><\/p>\n","protected":false},"author":2,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"_jetpack_memberships_contains_paid_content":false,"footnotes":""},"categories":[1],"tags":[],"class_list":["post-471","post","type-post","status-publish","format-standard","hentry","category-uncategorized"],"jetpack_featured_media_url":"","jetpack_sharing_enabled":true,"_links":{"self":[{"href":"https:\/\/porkrind.org\/missives\/wp-json\/wp\/v2\/posts\/471","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/porkrind.org\/missives\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/porkrind.org\/missives\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/porkrind.org\/missives\/wp-json\/wp\/v2\/users\/2"}],"replies":[{"embeddable":true,"href":"https:\/\/porkrind.org\/missives\/wp-json\/wp\/v2\/comments?post=471"}],"version-history":[{"count":13,"href":"https:\/\/porkrind.org\/missives\/wp-json\/wp\/v2\/posts\/471\/revisions"}],"predecessor-version":[{"id":484,"href":"https:\/\/porkrind.org\/missives\/wp-json\/wp\/v2\/posts\/471\/revisions\/484"}],"wp:attachment":[{"href":"https:\/\/porkrind.org\/missives\/wp-json\/wp\/v2\/media?parent=471"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/porkrind.org\/missives\/wp-json\/wp\/v2\/categories?post=471"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/porkrind.org\/missives\/wp-json\/wp\/v2\/tags?post=471"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}