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

Electron-rebuild migration breaks native module signing #7655

Closed
nnguyen01 opened this issue Jul 7, 2023 · 4 comments
Closed

Electron-rebuild migration breaks native module signing #7655

nnguyen01 opened this issue Jul 7, 2023 · 4 comments

Comments

@nnguyen01
Copy link

nnguyen01 commented Jul 7, 2023

  • Electron-Builder Version: 24.4.0
  • Node Version: 16.20.1
  • Electron Version: 25.2.0
  • Electron Type (current, beta, nightly): current
  • Target: Windows

Migrating to electron-rebuild breaks native module signing for some packages

PR that introduced the break:
#7196

Release that introduced the break:
https://github.com/electron-userland/electron-builder/releases/tag/v24.0.0-alpha.1

Error:

SignTool Error: This file format cannot be signed because it is not recognized.
SignTool Error: An error occurred while attempting to sign: C:\dev\project\release\build\win-unpacked\resources\app.asar.unpacked\node_modules\@nut-tree\libnut-darwin\build\Release\libnut.node

    at C:\dev\project\node_modules\builder-util\src\util.ts:133:18
    at ChildProcess.exithandler (node:child_process:410:5)
    at ChildProcess.emit (node:events:513:28)
    at maybeClose (node:internal/child_process:1100:16)
    at Process.ChildProcess._handle.onexit (node:internal/child_process:304:5)
From previous event:
    at processImmediate (node:internal/timers:466:21)
From previous event:
    at WinPackager.signApp (C:\dev\project\node_modules\app-builder-lib\src\winPackager.ts:407:27)
    at WinPackager.doSignAfterPack (C:\dev\project\node_modules\app-builder-lib\src\platformPackager.ts:332:21)
    at WinPackager.doPack (C:\dev\project\node_modules\app-builder-lib\src\platformPackager.ts:317:7)
    at WinPackager.pack (C\dev\project\node_modules\app-builder-lib\src\platformPackager.ts:136:5)
    at Packager.doBuild (C:\dev\project\node_modules\app-builder-lib\src\packager.ts:442:9)
    at executeFinally (C\dev\project\node_modules\builder-util\src\promise.ts:12:14)
    at Packager._build (C:\dev\project\node_modules\app-builder-lib\src\packager.ts:376:31)
    at Packager.build (C:\dev\project\node_modules\app-builder-lib\src\packager.ts:337:12)
    at executeFinally (C:\dev\project\node_modules\builder-util\src\promise.ts:12:14)

To reproduce add https://github.com/nut-tree/nut.js as a native dependency and try code signing with v24.0.0-alpha.1 vs v23.6.0.

@nnguyen01 nnguyen01 changed the title Migrating to electron-rebuild breaks native module signing Electron-rebuild migration breaks native module signing Jul 7, 2023
@mmaietta
Copy link
Collaborator

Are you codesigning cross-platform?
This seems related to #7652

@nnguyen01
Copy link
Author

nnguyen01 commented Jul 10, 2023

No, I'm signing a windows app on windows

@Julusian
Copy link
Contributor

I've just encountered this with v24.4.0 of electron builder and a different native library.

Looking at the logs, with v23:

2023-07-15T15:19:33.3128862Z $ D:\a\companion\companion\launcher\node_modules\.bin\electron-builder --publish=never --x64 --win
2023-07-15T15:19:33.9989484Z   • electron-builder  version=23.6.0 os=10.0.17763
2023-07-15T15:19:34.0040080Z   • loaded configuration  file=package.json ("build" field)
2023-07-15T15:19:34.0055211Z   • author is missed in the package.json  appPackageFile=D:\a\companion\companion\launcher\package.json
2023-07-15T15:19:34.2858029Z   • packaging       platform=win32 arch=x64 electron=24.6.3 appOutDir=D:\a\companion\companion\electron-output\win-unpacked
2023-07-15T15:19:34.4097121Z   • downloading     url=https://github.com/electron/electron/releases/download/v24.6.3/electron-v24.6.3-win32-x64.zip size=99 MB parts=4
2023-07-15T15:19:34.7061437Z   • downloaded      url=https://github.com/electron/electron/releases/download/v24.6.3/electron-v24.6.3-win32-x64.zip duration=388ms
2023-07-15T15:19:40.4527937Z   • signing         file=D:\a\companion\companion\electron-output\win-unpacked\resources\node-runtime\node.exe certificateFile=C:\Users\RUNNER~1\AppData\Local\Temp\t-FHhALN\0.p12
2023-07-15T15:19:40.6763542Z   • downloading     url=https://github.com/electron-userland/electron-builder-binaries/releases/download/winCodeSign-2.6.0/winCodeSign-2.6.0.7z size=5.6 MB parts=1
2023-07-15T15:19:40.7845786Z   • downloaded      url=https://github.com/electron-userland/electron-builder-binaries/releases/download/winCodeSign-2.6.0/winCodeSign-2.6.0.7z duration=302ms
2023-07-15T15:19:49.6935716Z   • signing         file=D:\a\companion\companion\electron-output\win-unpacked\Companion.exe certificateFile=C:\Users\RUNNER~1\AppData\Local\Temp\t-FHhALN\0.p12
2023-07-15T15:19:51.2603154Z   • building        target=nsis file=D:\a\companion\companion\electron-output\companion-win64.exe archs=x64 oneClick=false perMachine=true
2023-07-15T15:19:51.4674590Z   • downloading     url=https://github.com/electron-userland/electron-builder-binaries/releases/download/nsis-3.0.4.1/nsis-3.0.4.1.7z size=1.3 MB parts=1
2023-07-15T15:19:51.4932569Z   • downloaded      url=https://github.com/electron-userland/electron-builder-binaries/releases/download/nsis-3.0.4.1/nsis-3.0.4.1.7z duration=205ms
2023-07-15T15:19:51.7754227Z   • signing         file=D:\a\companion\companion\electron-output\win-unpacked\resources\elevate.exe certificateFile=C:\Users\RUNNER~1\AppData\Local\Temp\t-FHhALN\0.p12
2023-07-15T15:21:31.2626001Z   • downloading     url=https://github.com/electron-userland/electron-builder-binaries/releases/download/nsis-resources-3.4.1/nsis-resources-3.4.1.7z size=731 kB parts=1
2023-07-15T15:21:31.2861704Z   • downloaded      url=https://github.com/electron-userland/electron-builder-binaries/releases/download/nsis-resources-3.4.1/nsis-resources-3.4.1.7z duration=222ms
2023-07-15T15:21:33.1083707Z   •   Signing NSIS uninstaller  file=D:\a\companion\companion\electron-output\__uninstaller-nsis-companion-launcher.exe certificateFile=C:\Users\RUNNER~1\AppData\Local\Temp\t-FHhALN\0.p12
2023-07-15T15:21:36.3596910Z   • signing         file=D:\a\companion\companion\electron-output\companion-win64.exe certificateFile=C:\Users\RUNNER~1\AppData\Local\Temp\t-FHhALN\0.p12

v24:

2023-07-15T16:54:56.9540907Z $ D:\a\companion\companion\launcher\node_modules\.bin\electron-builder --publish=never --x64 --win
2023-07-15T16:54:58.0088928Z   • electron-builder  version=24.4.0 os=10.0.17763
2023-07-15T16:54:58.0164245Z   • loaded configuration  file=package.json ("build" field)
2023-07-15T16:54:58.0179652Z   • author is missed in the package.json  appPackageFile=D:\a\companion\companion\launcher\package.json
2023-07-15T16:54:58.1952694Z   • executing @electron/rebuild  arch=x64 version=25.3.0 appDir=D:\a\companion\companion\launcher
2023-07-15T16:54:58.5182335Z   • packaging       platform=win32 arch=x64 electron=25.3.0 appOutDir=D:\a\companion\companion\electron-output\win-unpacked
2023-07-15T16:54:58.7021760Z   • downloading     url=https://github.com/electron/electron/releases/download/v25.3.0/electron-v25.3.0-win32-x64.zip size=99 MB parts=4
2023-07-15T16:54:59.1229133Z   • downloaded      url=https://github.com/electron/electron/releases/download/v25.3.0/electron-v25.3.0-win32-x64.zip duration=547ms
2023-07-15T16:55:05.0173649Z   • signing         file=D:\a\companion\companion\electron-output\win-unpacked\resources\pre***\julusian-image-rs.win32-x64-msvc.node certificateFile=C:\Users\RUNNER~1\AppData\Local\Temp\t-e2Hojd\0.p12
2023-07-15T16:55:05.0175155Z   • signing         file=D:\a\companion\companion\electron-output\win-unpacked\resources\pre***\julusian-image-rs.linux-x64-gnu.node certificateFile=C:\Users\RUNNER~1\AppData\Local\Temp\t-e2Hojd\0.p12
2023-07-15T16:55:05.0176243Z   • signing         file=D:\a\companion\companion\electron-output\win-unpacked\resources\pre***\julusian-image-rs.darwin-arm64.node certificateFile=C:\Users\RUNNER~1\AppData\Local\Temp\t-e2Hojd\0.p12
2023-07-15T16:55:05.0177507Z   • signing         file=D:\a\companion\companion\electron-output\win-unpacked\resources\pre***\julusian-image-rs.linux-arm64-gnu.node certificateFile=C:\Users\RUNNER~1\AppData\Local\Temp\t-e2Hojd\0.p12
2023-07-15T16:55:05.0178552Z   • signing         file=D:\a\companion\companion\electron-output\win-unpacked\resources\pre***\julusian-image-rs.darwin-x64.node certificateFile=C:\Users\RUNNER~1\AppData\Local\Temp\t-e2Hojd\0.p12
2023-07-15T16:55:05.0179513Z   • downloading     url=https://github.com/electron-userland/electron-builder-binaries/releases/download/winCodeSign-2.6.0/winCodeSign-2.6.0.7z size=5.6 MB parts=1
2023-07-15T16:55:05.0180372Z   • downloaded      url=https://github.com/electron-userland/electron-builder-binaries/releases/download/winCodeSign-2.6.0/winCodeSign-2.6.0.7z duration=445ms
2023-07-15T16:55:06.1201507Z   ⨯ Exit code: 1. Command failed: C:\Users\runneradmin\AppData\Local\electron-builder\Cache\winCodeSign\winCodeSign-2.6.0\windows-10\x64\signtool.exe sign /t http://timestamp.digicert.com /f 

There are some other changes covered here, and this project is doing some weird stuff, but what I notice from these logs is that the file that were picked to be signed have completely changed in v24.
It looks like it wasnt attempting to sign any .node files in v23, and instead found the various .exe files, and in v24 it is now finding all the .node files and none of the .exe files.

One thing to note is that the native library this is failing on includes the .node files for every platform into the npm package. Some manual work is being done to copy them to be electron resources, because of our unusual build process. The presence of these non-windows .node files is what is causing electron-builder to fail.

I guess this should be possible to workaround, but pruning out the unnecessary .node files as part of a script run before the signing happens. With an added benefit of reducing the install size

@mmaietta
Copy link
Collaborator

mmaietta commented Jul 20, 2023

Please try new release 24.6.3

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

3 participants