Search code examples
macoscode-signingcode-signing-certificate

How to codesign dmg and App inside it?


I have a dmg with application inside it. I have purchased apple developer license and i have succeeded in signing the dmg using developer certificate. I checked the dmg it is signed and accepted success by Gatekeeper. I have used Sierra 10.12.5 to coding

I then copied and ran the installer and app. But Running the App throws can't be opened because it is from unidentified developer.

Running the App throws unidentifed developer

enter image description here

codesign --verify --deep  --verbose=2 MyQt.app
MyQt.app: code object is not signed at all
In architecture: x86_64

Is it possible to codesign dmg and recursively all content inside including the App?


Solution

  • You should sign .app with Developer ID certificate You can generate it at developer.apple.com if you are a Team

    codesign --force --deep -s DeveloperIDCertificate --keychain pathToKeychain YourApp.app

    --force will replica your previous signature

    --deep will recursively sign your content

    -s DeveloperIDCertificate will sign app by identity. It should be like this: -s 123C3FF2VA

    --keychain is argument for keychain database folder, for Sierra usually it's /Users/username/Library/Keychains/login.keychain-db