Skip to content
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

feat(mac): Add option to enable hardened-runtime #3858

Conversation

loremattei
Copy link
Contributor

This PR adds the option to enable the hardened runtime option during code sign for Mac builds.
The option is already supported by electron-osx-sign, so it's just a matter of passing the flag down.

Hardened runtime is a requirement for app notarization.

@sindresorhus
Copy link

I would recommend defaulting it to true as most will want to enable it since notarization (which requires hardened runtime) is required for apps with a new Developer ID and will be required for everyone in a future macOS release.

https://developer.apple.com/documentation/security/notarizing_your_app_before_distribution

@loremattei loremattei force-pushed the feat-add-macos-hardened-runtime branch from ee62a89 to 1de725c Compare April 26, 2019 08:33
@loremattei loremattei force-pushed the feat-add-macos-hardened-runtime branch from 1de725c to 9fcf8af Compare April 26, 2019 09:11
@loremattei
Copy link
Contributor Author

loremattei commented Apr 26, 2019

I would recommend defaulting it to true as most will want to enable it since notarization (which requires hardened runtime) is required for apps with a new Developer ID and will be required for everyone in a future macOS release.

Yep! It's true that it will be required for everyone, though I defaulted it to false because:

  • codesign and electron-osx-sign default to false, so it may be a bit confusing to have a different default here.
  • It seems that a lot of Electron apps break when hardened runtime is enabled if proper entitlements are not provided, so I think that setting the default to true would be disruptive for many people.

Does it make sense?

@thelifenadine
Copy link

Thanks @loremattei, I'll be using this as soon as it gets released!

@NickTikhonov
Copy link

This is both excellent and exciting @loremattei

@easyCZ
Copy link

easyCZ commented May 2, 2019

This feature is a must. Without it, electron-builder likely loses users as it would no longer provide the ability to support MacOS apps, which is its tagline...

Please consider merging this feature soon to continue enabling awesome cross platform packaging tools.

@lottec
Copy link

lottec commented May 8, 2019

Thanks for this @loremattei 💯 What's holding up merging? Keen to start using this...

@develar develar closed this in 7d5f952 May 9, 2019
@develar
Copy link
Member

develar commented May 9, 2019

Thanks @loremattei, sorry for delay.

@martani
Copy link

martani commented May 14, 2019

Setting this flag to true causes the app to crash on startup. It's mentioned above that this could be the case of the proper entitlements are not set. I'm not setting any, are there examples of what entitlements need to be set to use this flag?

Thanks.

@loremattei
Copy link
Contributor Author

Hi @martani! You can find some info about the Hardened Runtime Entitlements here: https://developer.apple.com/documentation/security/hardened_runtime_entitlements.

I'd suggest to start with looking at allow-jit, allow-unsigned-executable-memory and allow-dyld-environment-variables.

@martani
Copy link

martani commented May 18, 2019

Thanks @loremattei. Adding those entitlements did the trick when Hardened Runtime is enabled.

@1009466147
Copy link

hi I see you said you added a option, is electron-osx-sign?, Where should I use it.

@loremattei
Copy link
Contributor Author

Hey @1009466147! It's hardenedRuntime. It defaults to false and you can enable it if you need to sign your app with the Hardened Runtime, for example if you want to notarize the app.

bahmutov added a commit to cypress-io/cypress that referenced this pull request Dec 4, 2019
that adds an option to use hardened Mac OS, which is necessary
for code notarization later.

See https://github.com/electron-userland/electron-builder/releases/tag/v20.41.0
and electron-userland/electron-builder#3858
brian-mann added a commit to cypress-io/cypress that referenced this pull request Mar 25, 2020
* [email protected]

* node12.8.1-chrome78-ff70

* Revert "node12.8.1-chrome78-ff70" for now

This reverts commit db2d521.

* update sendCommand to log on all sendcommands

* promisification in 6.x

* Revert "Revert "node12.8.1-chrome78-ff70" for now"

This reverts commit 57fe764.

* fix sendcommand

* fix cdp in electron

* fix desktop-gui test

* skip tests that will be fixed by #4973

* bump MAX_ALLOWED_FILE_SIZE :/

* update electron browser spec

* make new dialog code null-proof

* add failing e2e test for issue 5475

* bump electron packager

* add e2e snapshot

* update deprecated electron getters/setters

https://github.com/electron/electron/blob/7-1-x/docs/api/modernization/property-updates.md

* build and test on Mac

* use electron-builder 20.41.0

that adds an option to use hardened Mac OS, which is necessary
for code notarization later.

See https://github.com/electron-userland/electron-builder/releases/tag/v20.41.0
and electron-userland/electron-builder#3858

* electron-builder and pass hardenedRuntime: true

* uncomment build

* upload built binary on mac

* back to 20.41.0, trying after sign hook without success

* use current electron-builder alias instead of build

* retry smoke test on first failure

* testing

* trying to notarize signed app (that does not have node_modules yet)

* env variable names

* copy node_modules ourselves

* build and bundle binary on mac on circle, inject new context

* enable build steps before electron build

* increase mac build timeout

* update build folder on mac

* uncomment actual electron build command

* set linux target to zip

* set zip as target for all platforms

* updated steps

* put notarization hook back

* tweaks for icons

* remove dist electron before code sign

* icons per platform

* make node_modules copy path platform-specific

* fix linux build unpacked folder

* build mac

* fix lint

* test new mac binary against kitchensink

* working on Linux build

* try building entire thing on Linux

* removing correct electron dist folder

* increase zip size limit for now

* add folder rename on Linux from linux-unpacked to Cypress

* print file sizes before zipping

* move linux-unpacked to build dir function

* try deleting second electron file, but code signing probably would not work

* test windows build [build binary]

* ignore tsc errors

* windows build path

* windows [build binary]

* update windows build folder

* increase binary build timeout on Mac

* no need to pass our dist folder

* adding explicit list of additional binaries to code sign on mac

* yarn lock

* uncomment necessary build steps

* electron dir for Linux

* yarn lock again

* back to execa v3

* use execa v4 in packages launcher

* yarn lock again and again

* updated tests that use execa

* print build folder

* add executable name on Linux

* get rid of execa.shell in build scripts

* remove old and commented out code

* need to test building binary on Windows

* throw error from after sign hook if fails

* use execa to zip

* yarn lock

* fix after merge variable

* update test

* add nohoist ffmpeg installer

* patch

* yarn types pass

* yarn lock has binary

Co-authored-by: Zach Bloomquist <[email protected]>
Co-authored-by: Brian Mann <[email protected]>
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

Successfully merging this pull request may close these issues.

9 participants