How to re-sign an app on a Mac

I recently changed the Info.plist file for nextcloud.app so that it would stop using the discrete GPU. However, this seemed to introduce a new issue where, apparently due to my changes to the Info.plist, the code signature for the app was no longer valid:

Feb 18 00:28:54 bardiel amfid[260]: /Applications/nextcloud.app/Contents/MacOS/nextcloud signature not valid: 0xfffefa2a
Feb 18 00:28:54 bardiel kernel[0]: proc 811: load code signature error 4 for file "nextcloud"
Feb 18 00:28:56 bardiel usernoted[269]: Failed to validate application at /Applications/nextcloud.app -67030
Feb 18 00:28:56 bardiel com.apple.SecurityServer[83]: suppressing keychain prompt /Applications/nextcloud.app(811); code signing check failed rc=-67030

This meant that the app was no longer allowed to access the Keychain, and the only way I found out was by inspecting system.log in Console.app. Thus nextcloud.app would ask me for a login every time it started - the primary symptom.

While waiting for the Nextcloud developers to work on the aforementioned issue, an interim fix is as follows:

  1. Follow this guide from Apple to "obtain a self-signed certificate using Certificate Assistant".
  2. Perform the following command in Terminal.app:
    $ sudo codesign -s "My Certificate Name" -fv /Applications/Nextcloud.app
    
    

You should now be able to launch the app and have it prompt you for Keychain access.


Last modified on 18 Feb 2019 at 12:51:03 AM EST ET