{"id":1567,"date":"2013-03-04T16:26:25","date_gmt":"2013-03-04T16:26:25","guid":{"rendered":"http:\/\/blog.designed79.co.uk\/?p=1567"},"modified":"2016-02-08T19:11:46","modified_gmt":"2016-02-08T19:11:46","slug":"re-signing-a-modified-apple-application","status":"publish","type":"post","link":"https:\/\/blog.designed79.co.uk\/?p=1567","title":{"rendered":"Re-Signing a Modified Apple Application"},"content":{"rendered":"<p><b>Obtaining a Code Signing Certificate<\/b><\/p>\n<p>In order to sign applications, you need to have a code signing certificate in your keychain. You can purchase one from one of the certificate authorities, such as Verisign, Thawte, or RSA, but they&#8217;re fairly expensive that way.<\/p>\n<p>If you&#8217;re doing it just to modify applications for your own use (or you&#8217;re a freeware or shareware developer who doesn&#8217;t want the independent verification), you can generate your own certificate to use. This is done using the Keychain Access application, in the Utilities folder. Here&#8217;s how:<\/p>\n<p>1. Open Keychain Access.<br \/>\n2. Go to the Keychain Access menu, and under Certificate Assistant, choose Create a Certificate<br \/>\n3. Name your Certificate. (I recommend using something other than your first and last names)<br \/>\n4. For Type, choose Self Signed Root.<br \/>\n5. Make sure Let me override defaults is checked and click Continue.<br \/>\n6. Under Serial Number, use a random number. Just make sure there is no other certificate on your system with the same name and serial number<br \/>\n7. Give yourself a sufficiently long validity period. For a little over 5 years, use 2000 days. For almost 11 years, choose 4000 days.<br \/>\n8. Under Certificate Type, choose Code Signing, and click Continue.<br \/>\n9. Enter your personal information on the next screen. Have fun with Organization and Organizational Unit. After all, this is for your own personal use. Don&#8217;t use &#8220;Apple.&#8221; I myself used something like &#8220;Orange Computer&#8221; for Organization and &#8220;Hacking Department&#8221; for Organizational Unit. Click Continue when all has been filled out.<br \/>\n10. For Key Pair Information, accept the defaults and click Continue.<br \/>\n11. For Key Usage Extension, accept the defaults and click Continue.<br \/>\n12. For Extended Key Usage Extension, accept the defaults and click Continue.<br \/>\n13. For Basic Constraints Extension, accept the defaults and click Continue.<br \/>\n14. For Subject Alternate Name Extension, accept the defaults and click Continue.<br \/>\n15. Use your &#8220;login&#8221; keychain to store the certificate and click Continue.<br \/>\n16. Now you have to set your certificate to be &#8220;trusted.&#8221;<br \/>\n17. Go to your keychain, and right click (control click) on the new certificate you made and choose Get Info.<br \/>\n18. Open the triangle next to Trust.<br \/>\n19. Go down to Code Signing, and choose Always Trust.<br \/>\n20. Close the box. The system will ask for your admin password. Enter it and click OK.<\/p>\n<p>You&#8217;re done, and you have a certificate you can use for signing your own code, or re-signing someone else&#8217;s code that you&#8217;ve modified or tinkered with.<\/p>\n<p><b>Re-Signing a Modified Apple Application<\/b><\/p>\n<p>Before you re-sign an application that you&#8217;ve modified, make sure you&#8217;re done with the modifications, because otherwise you&#8217;ll have to sign it again. Once you&#8217;ve re-signed the application, it will look to the system like a different application than the one Apple provided. For this reason, make sure you do this on a copy of the Apple-supplied application. Besides, you&#8217;ve got to make sure that an update from Apple doesn&#8217;t screw up your modifications, or vice versa.<\/p>\n<p>Re-signing the application is quite simple.<\/p>\n<p>1. Open Terminal.<br \/>\n2. Type &#8220;codesign -f -s (name of certificate) \/path\/to\/application<\/p>\n<p>(name of certificate) is the name you gave your certificate in the creating a certificate section. Remember that you&#8217;ll have to escape any spaces or other nonstandard characters that appear. For example, if your certificate were called &#8220;Harry Potter&#8217;s Certificate,&#8221; you would use &#8220;Harry\\ Potter\\&#8217;s\\ Certificate.&#8221; As an alternative, you can use a portion (substring) of the certificate&#8217;s name as long as that portion does not appear anywhere else in your keychain. So you could type &#8220;Potter&#8221; instead of the full string with escaped characters.<\/p>\n<p>Once again, you can type &#8220;codesign -f -s (name of certificate) &#8221; and drag the application to be resigned from the Finder to the Terminal window to enter the path name if you don&#8217;t want to type it out yourself.<\/p>\n<p>When you&#8217;re done, you can use &#8220;codesign -dvvvv \/path\/to\/application&#8221; to verify that the signature has changed.<\/p>\n<p>NOTE: you may want to add the &#8211;deep option, this will codesign any plugins or other code in the bundle<\/p>\n","protected":false},"excerpt":{"rendered":"<p>Obtaining a Code Signing Certificate In order to sign applications, you need to have a code signing certificate in your keychain. You [&hellip;]<\/p>\n","protected":false},"author":2,"featured_media":0,"comment_status":"closed","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[1],"tags":[],"class_list":["post-1567","post","type-post","status-publish","format-standard","hentry","category-info-on-tech"],"_links":{"self":[{"href":"https:\/\/blog.designed79.co.uk\/index.php?rest_route=\/wp\/v2\/posts\/1567","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/blog.designed79.co.uk\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/blog.designed79.co.uk\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/blog.designed79.co.uk\/index.php?rest_route=\/wp\/v2\/users\/2"}],"replies":[{"embeddable":true,"href":"https:\/\/blog.designed79.co.uk\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=1567"}],"version-history":[{"count":0,"href":"https:\/\/blog.designed79.co.uk\/index.php?rest_route=\/wp\/v2\/posts\/1567\/revisions"}],"wp:attachment":[{"href":"https:\/\/blog.designed79.co.uk\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=1567"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/blog.designed79.co.uk\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=1567"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/blog.designed79.co.uk\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=1567"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}