electron / osx-sign

Codesign Electron macOS apps
BSD 2-Clause "Simplified" License
560 stars 96 forks source link

electron-osx-sign does not handle app with spaces #237

Open lcheunglci opened 3 years ago

lcheunglci commented 3 years ago

I have an electron app that has spaces in the name "My App.app" and ran into an issue with codesigning.

I ran the following:

electron-osx-sign "My App.app" --platform=darwin --type=distribution --identity="Developer ID: my company id" --keychain="..." --entitlements="..." --hardened-runtime --entitlements-inherit="..." --no-gatekeeper-assess

Sign failed: Command failed: codesign --sign SOME_GUID --force --keychain ... --timestamp --options runtime --entitlements ... My App.app/Contents/_CodeSignature: No such file or directory

However, if I go into the My App.app/Contents/MacOS/My\ App and rename it without space, it'll codesign successfully, but the app does not launch unless the executable and the .app match so I rename it back after it's signed but when I use xcrun to notarize the app, I get an invalid package error. It points to the binary that I renamed saying "The signature of the binary is invalid."

Are electron applications with spaces in the name not allowed? or is this a bug?

Also, this is running on macOS Mojave 10.14.6.

lcheunglci commented 3 years ago

I found 2 workarounds. One was to change the Product Name in the package.json with no space, and the other was by renaming the generated .app with no spaces instead of renaming the executable inside and I was able to run electron-osx-sign to codesign successfully and was also able to notarize successfully.

I also manage to fix electron-osx-sign so that I can use space in the PR https://github.com/electron/electron-osx-sign/pull/238

lcheunglci commented 2 years ago

I've added a comment in the PR #238, perhaps, it's a better if the documentation indicates that app name with spaces are not supported in this tool and throw an exception during validation, so it won't fail during the actual codesign step.