Skip to content

Could not get code signature for running application #7476

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
arkakkar opened this issue Oct 4, 2016 · 27 comments
Closed

Could not get code signature for running application #7476

arkakkar opened this issue Oct 4, 2016 · 27 comments

Comments

@arkakkar
Copy link

arkakkar commented Oct 4, 2016

  • Electron version: 1.41
  • Operating system: osx

My certificate works fine when I package the app by running
"electron-packager . $npm_package_productName --app-version=$npm_package_version --version=1.4.1 --out=../mac_builds --ignore='^/builds$' --platform=darwin --arch=x64 --icon=./app/icons/mac.icns --tmpdir=false --osx-sign.identity='Mac Developer: Arjun Kakkar (HQ3PJX83VN)' --overwrite"

but throws the error when running npm start

@MarshallOfSound
Copy link
Member

@arkakkar Sounds like you are using the autoUpdater API on a non-codesigned application. As per the autoUpdater documentation

http://electron.atom.io/docs/api/auto-updater/#macos

Note: Your application must be signed for automatic updates on macOS. This is a requirement of Squirrel.Mac.

@MarshallOfSound
Copy link
Member

For further clarification, the packager signs your app. When you run npm start the pre-built Electron executable is not signed

@arkakkar
Copy link
Author

arkakkar commented Oct 4, 2016

How can I sign the electron executable so that auto updater runs fine when I use npm start with the source and not just after the app is packed so that I could also debug my code.
I want to debug the main process with the auto updater setFeedUrl set on a non packaged app like when I run from the terminal

@arkakkar
Copy link
Author

arkakkar commented Oct 4, 2016

The issue is resolved. Code signing electron executable working. Thanks

@jsgv
Copy link

jsgv commented Mar 2, 2017

@arkakkar How did you sign the Electron executable?

@rvillanueva
Copy link

@JesusGalvan https://github.com/electron-userland/electron-builder/wiki/Code-Signing

How to Export Certificate on macOS

Open Keychain.
Select login keychain, and My Certificates category.
Select all required certificates (hint: use cmd-click to select several):

Developer ID Application: to sign app for macOS.
3rd Party Mac Developer Application: and 3rd Party Mac Developer Installer: to sign app for MAS (Mac App Store).
Developer ID Application: and Developer ID Installer to sign app and installer for distribution outside of the Mac App Store.
Please note – you can select as many certificates, as need. No restrictions on electron-builder side. All selected certificates will be imported into temporary keychain on CI server.

Open context menu and Export.

@jdell64
Copy link

jdell64 commented Oct 25, 2017

So, maybe this is too much information, but it took me a few hours to figure out how to sign the .app file. I'll list out what I did in the off chance it helps someone else (I am completely new at developing on a mac):

prereqs: you have electron-packager installed, you have electron-osx-sign installed, and you can build your target.

  1. You need to create a cert through xcode. Additionally, you need to have an apple developer account:
    1. go to https://developer.apple.com/account and make sure you have accepted the terms.
    2. install xcode through the app store. Open it.
    3. On the accounts tab, add your apple id. Select it.
    4. Select Manage Certificates.
    5. Add whatever cert you are using. I am using a free account, so I did "Mac Development"
      Take note of the cert name.
  2. You have a cert, now you can sign the app. Assuming you were able to build it (I built mine using something like: "electron-packager . $npm_package_productName --app-version=$npm_package_version --out=builds --platform=darwin --arch=x64 --overwrite",) you can run something like:
    "electron-osx-sign ./builds/$npm_package_productName-darwin-x64/$npm_package_productName.app/ --identity='Mac Developer: [my email] ([this code thing])'" (the name of the cert).

Again, sorry if that is not the original question, but I was stuck for a few hours.

@phuze
Copy link

phuze commented Nov 22, 2017

Although closed, this issue helped me out so I'm leaving some useful information for future readers.

To further clarify a few points in regards to @jdell64 post -- the Accounts tab can be accessed by first opening the Preferences window in XCode which can be found under the File menu.

The proper certificate name cannot be seen through XCode. Once you've added a certificate, you'll need to open Keygen Access.app (use Spotlight search), click My Certificates from the left menu. Here you will see your certificate.

For example:

Mac Developer: batman@marvel.com (123ABCDE45)

I will further add, that if you are using electron-builder to package your application, then you will need to export your certificates. Read more about code signing and exporting your certificates.

It is important to note with regards to auto updating, the use of a "Mac Development" certificate, to the best of my knowledge, would only enable auto updating on your own Mac. If you are releasing your application for others, you will need to add both Developer ID Application and Developer ID Installer certificates, which can only be added if you have a valid Developer ID which you get when you purchase a subscription to the Apple Developer Program.

@erynkyo
Copy link

erynkyo commented Dec 19, 2017

i met the same issue today .if you want to running by dev mode,you should sign electron.app.
step 1:create a new login type key in your mac.
step 2: go into your electron dist folder.ex:{project}/node_modules/electron/dist with cmd.
step 3:codesign --deep --force --verbose --sign "{your key name}" electron.app.
And then ,very thing will be ok.
ps:i am not good at english, forgive me :(

@shanesmith
Copy link

Building on @erynkyo I've found that you don't need to create a new key and can ad-hoc code sign by providing just a dash for the --sign param

codesign --deep --force --verbose --sign - electron.app

@zewa666
Copy link

zewa666 commented Mar 9, 2018

@shanesmith awesome solution.
For anyone searching for a way to sign your app during development, just use above to sign your node_modules/electron/dist/Electron.app and you should be good to go to debug the autoUpdater process

@onassar
Copy link

onassar commented Mar 9, 2018

Wow what a rabbit hole I went down to figure this out. Thanks everyone here for the pieces that got me to where I needed to go. The following is what I needed to do:

From within the app directory that electron-forge set up for me, I had to run the following:

codesign --deep --force --verbose --sign "Mac Developer: MY NAME (MY CODE)" node_modules/electron-prebuilt-compile/node_modules/electron/dist/Electron.app

This did the job for me (finally).

@mlynch
Copy link

mlynch commented Oct 25, 2018

You can also just wrap the autoUpdate calls in a try/catch, 100x simpler than trying to code sign development builds.

@joshuapinter
Copy link

joshuapinter commented Jan 16, 2019

Just as a tip, I added the following script and postinstall to my package.json file so that my development Electron.app always gets signed after an npm install:

scripts: {
  "sign-dev-electron-app": "codesign --deep --force --verbose --sign - node_modules/electron-prebuilt-compile/node_modules/electron/dist/Electron.app",
  "postinstall": "npm run sign-dev-electron-app"
}

Note: I'm using electron-forge so that's my location of Electron.app. Use the path to your Electron.app.

@Dammmien
Copy link

Dammmien commented Feb 4, 2019

I have this error but with a signed app, does someone know what can be the cause ?

@joshuapinter
Copy link

@Dammmien My guess would be the signature is incorrect. Look for errors on signing, etc.

@limichange
Copy link

codesign --deep --force --verbose --sign - node_modules/electron/dist/Electron.app

@500apps2
Copy link

Iam having code that is written to create a desktop app using electron. i have used electron-packager and finally got a .dmg file. Getting error while importing the electron code into xcode. How can i add the code into xcode and how can i attach signin certificates for my .dmg file in macos???

@PathToLife
Copy link

After Running:

codesign --deep --force --verbose --sign - node_modules/electron/dist/Electron.app

We get:

Electron.app/: code object is not signed at all

In subcomponent:

**/node_modules/electron/dist/Electron.app/Contents/Frameworks/Electron Framework.framework

Seems like this hack won't work anymore

@rmincling
Copy link

I also get the same as @PathToLife

@rancheng123
Copy link

I have signed my dev.app successfully using the following command :
codesign --deep --force --verbose --sign "Developer ID Application: XXX technology co., LTD (AQ5PV3824X)" /Users/deo/mxj-desktop-app/node_modules/electron/dist/Electron.app

, but the autoUpdater throw an error when I try to update my dev.app by dev mode,
the error is : Error: Could not locate update bundle for com.github.electron within file:///Users/deo/Library/Caches/com.github.electron.ShipIt/update.NwgbQDL/

@dko-slapdash
Copy link

I think this is because in dev mode something (looks like it's squirrel?) extracts this appId, "com.github.electron", from node_modules/electron/dist/Electron.app and not from package.json.

I spent 1h trying to figure out, where exactly does this happen (checking both electron source code and squirrel source code), but finally gave up.

Would be great if it was possible to substitute this string (to match one in package.json) in development mode (i.e. where the app is executed via electron path/to/dir/with/package_json). Any idea on how could this be done?..

@yanlee26
Copy link

codesign --deep --force --verbose --sign - node_modules/electron/dist/Electron.app

node_modules/electron/dist/Electron.app: signed app bundle with Mach-O thin (x86_64) [com.github.Electron]

@yanlee26
Copy link

Error: Could not locate update bundle for com.github.Electron within file:///Users/elliotyan/Library/Caches/com.github.Electron.ShipIt/update.puOMysF/

@linonetwo
Copy link

Hi, I can see the new version of the app is downloaded in the

~/Library/Application Support/Caches/tiddlygit-updater/pending/TiddlyGit-0.2.1-mac.zip

(my app's name is "tiddlygit", so the path is like this ↑)

And try to unzip and open it will result in The application "TiddlyGit" can’t be opened.

But this can be fixed by running:

chmod +x "~/Library/Application Support/Caches/tiddlygit-updater/pending/TiddlyGit/TiddlyGit.app/Contents/MacOS/TiddlyGit""

And just move this to the Application folder.

This can actually be done automatically in electron-builder.

@linonetwo
Copy link

My app is completely open-sourced, so I don't want to pay apple for signing.

@Krishnaraj-shankar
Copy link

Error: Code signature at URL file:///Users/krishna-pt5814/Library/Caches/com.Krishnaraj.autoupdater.ShipIt/update.Homm8pL/Autoupdater%20app.app/ did not pass validation: code has no resources but signature indicates they must be present

getting this error while the autoupdater downloads the updated version. I'm using electron-updater npm module

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests