How to sign electron app using electron forge?
Asked Answered
C

3

13

I am using electron forge for building and packaging my electron app.

How can I code sign my app (using electron forge) for windows and mac?

Electrong-forge: https://github.com/electron-userland/electron-forge

Chilton answered 29/9, 2017 at 2:1 Comment(2)
I could not sign using electron forge. I have ended up using electron builder. github.com/electron-userland/electron-builderChilton
Electron-forge uses electron-packager, so you can pass the appropriate configuration to the electron-forge command to get signing. See this link electronjs.org/docs/tutorial/code-signing#signing-macos-buildsBabirusa
L
9

EDIT: see https://mcmap.net/q/877374/-how-to-sign-electron-app-using-electron-forge bellow. electronPackagerConfig is now packagerConfig

Use packagerConfig key in your package.json.

Electron Forge uses Electron Packager under the hood and allows you to set the Electron Packager configuration in your package.json.

Here's an extract of what mine looks like in order to sign our packaged application file:

package.json

{ 
  "config": {
    "forge": {
      "packagerConfig": {
        "osxSign": {
          "identity": "Developer ID Application: Joshua Pinter (<your_key_code>)"
        }
      }
    }
  }
}

You can see that all the Electron Packager configurations can be put under the packagerConfig key.

NOTE: In older versions of Electron Forge, this was called electronPackagerConfig instead of packagerConfig.

Lanam answered 15/1, 2019 at 17:35 Comment(4)
Thanks for this addition. It would be great to have this documented on the official github repo. They might have added the docs by now.Chilton
@gba Docs are still pretty sparse, unfortunately.Lanam
To get the identity, you can type in the following command from the command prompt: ``` security find-identity -p codesigning -v ```Painstaking
If you are doing this via SSH, remember to security unlock-keychain before you run yarn make, as it will give you a very cryptic error: WARNING: code sign failed; please retry manually.... but not explain that it is simply the keychain being locked. You can of course run it in the Terminal.app and it will prompt you to unlock it, but OSX can't or won't prompt you remotely.Alluvial
L
2

electronPackagerConfig is now packagerConfig, e.g.:

{ 
  "config": {
    "forge": {
      "packagerConfig": {
        "osxSign": {
          "identity": "Developer ID Application: Company (id)"
        }
      }
    }
  }
}

Loveliesbleeding answered 1/11, 2019 at 20:19 Comment(3)
Thanks a lot, I was wondering why the accepted answer was not working!Bethany
when I open the app after signing with electron-forge, it crashes. Any idea why is this happening ?Percept
No but you could check Console (on MacOS) to see if there’s log output from the process. Or try running the app binary directly from Terminal to see if there are any error messages.Loveliesbleeding
L
0

Only signing the electron app won't let the app work in production, as GateKeeper will not allow the app to open. You need to sign the application and then perform notarization. Here is how you can do that with electron forge.

"packagerConfig": {
  "icon": "./resources/icon",
  "osxSign": {
    "identity": "Developer ID Application: Kiran Maniya (R8A8NS532)"
  },
  "osxNotarize": {
    "tool": "notarytool",
    "appleApiKey": "./signing/AuthKey_R8A8NS532.p8",
    "appleApiKeyId": "R8A8NS532",
    "appleApiIssuer": "30651f9c-0046-4d6a-aba3-db72ff6c32ef"
  }
},

You can retrieve the identity name by running the command given below. Remember, The Developer ID Installer certificate is for apps distributed to the Mac App Store and Developer ID Application certificate is for apps distributed outside the Mac App Store.

security find-identity -p codesigning -v
Liquate answered 24/11, 2022 at 5:31 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.