electron-userland / electron-builder

A complete solution to package and build a ready for distribution Electron app with “auto update” support out of the box
https://www.electron.build
MIT License
13.68k stars 1.74k forks source link

signing hash algorithms 256 doesn't work EV Code Signing Certificate Windows 7 #2195

Closed SJ-AW closed 7 years ago

SJ-AW commented 7 years ago

Hi,

Since version 19.33.0+, the electron's build doesn't work when is signing my app.

When I try to deploy my app with DEBUG=electron-builder:

electron-builder 19.37.1
2017-10-13T12:46:48.382Z electron-builder Effective config:
appId: com.app.My-App
directories:
  output: dist_electron/electron-binaries
asar: true
files:
  - index.js
  - dist_electron/webapp-bundle
  - dist_electron/electron-main
  - dist_electron/electron-renderer
  - '!node_modules'
  - package.json
win:
  target: nsis
  icon: src/electron-app/icons/win-icon-app.ico
  certificateSubjectName: My certificate
nsis:
  artifactName: 'My-App-Setup-${version}.${ext}'
  shortcutName: My App
  menuCategory: true
  license: LICENSE
  installerIcon: src/electron-app/icons/win_installer_icon.ico
  installerHeader: src/electron-app/images/win-header-install.bmp
extraMetadata:
  name: My-App
  author:
    name: My Company Name

Rebuilding native production dependencies for win32:x64
2017-10-13T12:46:53.082Z electron-builder Spawning C:\Program Files\nodejs\node.exe C:\Users\SJA\AppData\Roaming\npm\node_modules\npm\bin\npm-cli.js rebuild uws@0.14.5
2017-10-13T12:46:53.082Z electron-builder cwd: D:\Projets\My-App

> uws@0.14.5 install D:\Projets\My-App\node_modules\uws
> node-gyp rebuild > build_log.txt 2>&1 || exit 0

uws@0.14.5 D:\Projets\My-App\node_modules\uws
2017-10-13T12:46:59.034Z electron-builder node.exe (10484) exited with exit code 0
Packaging for win32 x64 using electron 1.7.9 to dist_electron\electron-binaries\win-unpacked
2017-10-13T12:46:59.442Z electron-builder Spawning D:\Projets\My-App\node_modules\7zip-bin-win\x64\7za.exe x -bd C:\Users\SJA\AppData\Local\electron\Cache\electron-v1.7.9-win32-x64.zip -aoa -oD:\Projets\My-App\dist_electron\electron-binaries\win-unpacked

7-Zip (a) 17.01 beta (x64) : Copyright (c) 1999-2017 Igor Pavlov : 2017-08-28

Scanning the drive for archives:
1 file, 53893903 bytes (52 MiB)

Extracting archive: C:\Users\SJA\AppData\Local\electron\Cache\electron-v1.7.9-win32-x64.zip
--
Path = C:\Users\SJA\AppData\Local\electron\Cache\electron-v1.7.9-win32-x64.zip
Type = zip
Physical Size = 53893903

Everything is Ok

Files: 117
Size:       138386650
Compressed: 53893903
2017-10-13T12:47:00.642Z electron-builder 7za.exe (6084) exited with exit code 0
2017-10-13T12:47:03.683Z electron-builder Executing powershell.exe Get-ChildItem -Recurse Cert: -CodeSigningCert | Select-Object -Property Subject,PSParentPath,Thumbprint | ConvertTo-Json -Compress
2017-10-13T12:47:05.400Z electron-builder {"Subject":"CN=My certificate, O=My certificate, STREET=street, L=City, S=Region, C=FR, OID.1.5.7.1.5.1.3.60.2.1.3=FR, SERIALNUMBER=000 000 001, OID.5.5.4.16=Private Organization","PSParentPath":"Microsoft.PowerShell.Security\\Certificate::CurrentUser\\My","Thumbprint":"AC8AD71FEB42CA80C4399D6B848735D0E475CE37"}

2017-10-13T12:47:05.400Z electron-builder Auto-detect certificate store My (PSParentPath: Microsoft.PowerShell.Security\Certificate::CurrentUser\My)
2017-10-13T12:47:05.400Z electron-builder Auto-detect using of LocalMachine store
2017-10-13T12:47:05.440Z electron-builder No valid cached executable found, old digest: null, new digest: h/hh4VFHKiOD7nkx8cmVf94T7m0VB3XDuTbN0ZEtqoV2CgwsCZh4OcgQ51Z26R5KecOyzXElQCL+fb/gb7Pikg==
executable cache: 0s 9ms
2017-10-13T12:47:05.457Z electron-builder Executing C:\Users\SJA\AppData\Local\electron-builder\cache\winCodeSign\winCodeSign-1.9.0\rcedit.exe D:\Projets\My-App\dist_electron\electron-binaries\win-unpacked\My-App.exe --set-version-string FileDescription My-App --set-version-string ProductName My-App --set-version-string LegalCopyright Copyright © 2017 MyCompanyName --set-file-version 0.4.2 --set-product-version 0.4.2.0 --set-version-string InternalName My-App --set-version-string OriginalFilename  --set-version-string CompanyName MyCompanyName --set-icon D:\Projets\My-App\src\electron-app\icons\win-icon-app.ico
Signing My-App.exe (subject: "CN=My certificate, O=My certificate, STREET=street, L=City, S=Region, C=FR, OID.1.5.7.1.5.1.3.60.2.1.3=FR, SERIALNUMBER=000 000 001, OID.5.5.4.16=Private Organization", thumbprint: "AC8AD71FEB42CA80C4399D6B848735D0E475CE37", store: My (current user))
2017-10-13T12:47:05.647Z electron-builder Executing C:\Users\SJA\AppData\Local\electron-builder\cache\winCodeSign\winCodeSign-1.9.0\windows-10\x64\signtool.exe sign /t http://timestamp.verisign.com/scripts/timstamp.dll /sha1 AC8AD71FEB42CA80C4399D6B848735D0E475CE37 /s My /d My-App D:\Projets\My-App\dist_electron\electron-binaries\win-unpacked\My-App.exe
2017-10-13T12:47:05.659Z electron-builder env: {}
2017-10-13T12:50:04.012Z electron-builder Done Adding Additional Store
Successfully signed: D:\Projets\My-App\dist_electron\electron-binaries\win-unpacked\My-App.exe

2017-10-13T12:50:04.013Z electron-builder Executing C:\Users\SJA\AppData\Local\electron-builder\cache\winCodeSign\winCodeSign-1.9.0\windows-10\x64\signtool.exe sign /tr http://timestamp.comodoca.com/rfc3161 /sha1 AC8AD71FEB42CA80C4399D6B848735D0E475CE37 /s My /fd sha256 /td sha256 /d My-App /as D:\Projets\My-App\dist_electron\electron-binaries\win-unpacked\My-App.exe
2017-10-13T12:50:04.025Z electron-builder env: {}

The build stop at this point without error's return. When I try this line in cmd, I get:

C:\Users\SJA>C:\Users\SJA\AppData\Local\electron-builder\cache\winCodeSign\winCodeSign-1.9.0\windows-10\x64\signtool.exe sign /tr http://timestamp.comodoca.com/rfc3161 /sha1 AC8AD71FEB42CA80C4399D6B848735D0E475CE37 /s My /fd sha256 /td sha256 /d My-App /as D:\Projets\My-App\dist_electron\electron-binaries\win-unpacked\My-App.exe
Done Adding Additionnal Store
SignTool Error: An unexpected internal error ocurred.
Error information: "Error: SignerSign() failed" (-2147024846/0x80070032)

On https://social.technet.microsoft.com/wiki/contents/articles/15260.windows-update-agent-error-codes.aspx, 0x80070032 -2147024846 ERROR_NOT_SUPPORTED. So the first signature in sha1 work but not the second in sha256.

Electron-builder's versions before 19.33.0 work like a charm, example with 19.32.2:

...

2017-10-13T13:25:40.753Z electron-builder 7za.exe (3032) exited with exit code 0
2017-10-13T13:25:43.822Z electron-builder No valid cached executable found, old digest: null, new digest: h/hh4VFHKiOD7nkx8cmVf85T7m0VB3XDuTbN0ZEtqoV2CgwsCZh4OcgQ51Z26R5KecOyzXElQCL+fb/gb7Pikg==
executable cache: 0s 5ms
2017-10-13T13:25:43.838Z electron-builder Executing C:\Users\SJA\AppData\Local\electron-builder\cache\winCodeSign\winCodeSign-1.9.0\rcedit.exe D:\Projets\WebApp\aw-platform\dist_electron\electron-binaries\win-unpacked\My-App.exe --set-version-string FileDescription My-App --set-version-string ProductName My-App --set-version-string LegalCopyright Copyright © 2017 MyCompanyName --set-file-version 0.4.2 --set-product-version 0.4.2.0 --set-version-string InternalName My-App --set-version-string OriginalFilename  --set-version-string CompanyName MyCompanyName --set-icon D:\Projets\WebApp\aw-platform\src\electron-app\icons\win-icon-app.ico
Signing My-App.exe (certificate subject name: "MyCertificate")
2017-10-13T13:25:44.025Z electron-builder Executing C:\Users\SJA\AppData\Local\electron-builder\cache\winCodeSign\winCodeSign-1.9.0\windows-6\signtool.exe sign /t http://timestamp.verisign.com/scripts/timstamp.dll /n MyCertificate /d My-App D:\Projets\WebApp\aw-platform\dist_electron\electron-binaries\win-unpacked\My-App.exe
2017-10-13T13:25:44.041Z electron-builder env: {}
2017-10-13T13:26:05.966Z electron-builder Done Adding Additional Store
Successfully signed: D:\Projets\WebApp\aw-platform\dist_electron\electron-binaries\win-unpacked\My-App.exe

2017-10-13T13:26:05.966Z electron-builder Executing C:\Users\SJA\AppData\Local\electron-builder\cache\winCodeSign\winCodeSign-1.9.0\windows-6\signtool.exe sign /tr http://timestamp.comodoca.com/rfc3161 /n MyCertificate /fd sha256 /td sha256 /d My-App /as D:\Projets\WebApp\aw-platform\dist_electron\electron-binaries\win-unpacked\My-App.exe
2017-10-13T13:26:05.981Z electron-builder env: {}
2017-10-13T13:26:09.115Z electron-builder Done Adding Additional Store
Successfully signed: D:\Projets\WebApp\aw-platform\dist_electron\electron-binaries\win-unpacked\My-App.exe

...

So I have no idea what can I do to solve this problem?

Thanks very much

SJ-AW commented 7 years ago

Hi,

If that can help with the last electron-builder version when I build my app I have:

Tue, 31 Oct 2017 17:25:16 GMT app:build:webpack-compiler Compilation completed successfully.
electron-builder 19.43.0
Rebuilding native production dependencies for win32:x64
Packaging for win32 x64 using electron 1.7.9 to dist_electron\electron-binaries\win-unpacked
Signing My-App.exe (subject: "CN=My Company SA, O=My Company SA, STREET=street, L=city, S=Hauts-de-Seine, C=FR, OID.1.3.6.1.4.1.361.30.2.4.3=FR, SERIALNUMBER=350 238 061, OID.1.2.3.17=Private Organization", thumbprint: "DC82971FEB42CA84C43EAB6B8A4737D0E485CE3B", store: My (current user))
Tue, 31 Oct 2017 17:27:06 GMT app:bin:deploy:deploy-electron Error: Exit code: 1. Command failed: C:\Users\User\AppData\Local\electron-builder\cache\winCodeSign\winCodeSign-1.9.0\windows-10\x64\signtool.exe sign /tr http://timestamp.comodoca.com/rfc3161 /sha1 DC82971FEB42CA84C43EAB6B8A4737D0E485CE3B /s My /fd sha256 /td sha256 /d My-App /as D:\Projets\MyApp\dist_electron\electron-binaries\win-unpacked\My-App.exe
SignTool Error: An unexpected internal error has occurred.

Done Adding Additional Store
Error information: "Error: SignerSign() failed." (-2147024846/0x80070032)

SignTool Error: An unexpected internal error has occurred.

    at D:\Projets\MyApp\node_modules\builder-util\src\util.ts:117:16
    at ChildProcess.exithandler (child_process.js:211:5)
    at emitTwo (events.js:106:13)
    at ChildProcess.emit (events.js:191:7)
    at maybeClose (internal/child_process.js:886:16)
    at Process.ChildProcess._handle.onexit (internal/child_process.js:226:5)
From previous event:
    at exec (D:\Projets\MyApp\node_modules\builder-util\src\util.ts:85:3)
    at VmManager.exec (D:\Projets\MyApp\node_modules\electron-builder\src\vm\vm.ts:12:12)
    at D:\Projets\MyApp\node_modules\electron-builder\src\windowsCodeSign.ts:148:12
From previous event:
    at doSign (D:\Projets\MyApp\node_modules\electron-builder\out\windowsCodeSign.js:112:22)
    at defaultExecutor (D:\Projets\MyApp\node_modules\electron-builder\src\windowsCodeSign.ts:60:12)
    at D:\Projets\MyApp\node_modules\electron-builder\src\windowsCodeSign.ts:67:11
From previous event:
    at sign (D:\Projets\MyApp\node_modules\electron-builder\out\windowsCodeSign.js:45:21)
    at D:\Projets\MyApp\node_modules\electron-builder\src\winPackager.ts:261:15
    at next (native)
From previous event:
    at WinPackager.doSign (D:\Projets\MyApp\node_modules\electron-builder\out\winPackager.js:390:11)
    at D:\Projets\MyApp\node_modules\electron-builder\src\winPackager.ts:249:16
From previous event:
    at WinPackager.sign (D:\Projets\MyApp\node_modules\electron-builder\out\winPackager.js:370:11)
    at D:\Projets\MyApp\node_modules\electron-builder\src\winPackager.ts:338:16
From previous event:
    at WinPackager.signAndEditResources (D:\Projets\MyApp\node_modules\electron-builder\out\winPackager.js:447:11)
    at WinPackager.signApp (D:\Projets\MyApp\node_modules\electron-builder\src\winPackager.ts:353:17)
    at D:\Projets\MyApp\node_modules\electron-builder\src\platformPackager.ts:209:16
    at next (native)
    at runCallback (timers.js:666:20)
    at tryOnImmediate (timers.js:639:5)
    at processImmediate [as _immediateCallback] (timers.js:611:5)
From previous event:
    at WinPackager.doPack (D:\Projets\MyApp\node_modules\electron-builder\out\platformPackager.js:267:11)
    at D:\Projets\MyApp\node_modules\electron-builder\src\platformPackager.ts:115:16
    at next (native)
From previous event:
    at WinPackager.pack (D:\Projets\MyApp\node_modules\electron-builder\out\platformPackager.js:190:11)
    at D:\Projets\MyApp\node_modules\electron-builder\src\packager.ts:260:24
From previous event:
    at Packager.doBuild (D:\Projets\MyApp\node_modules\electron-builder\out\packager.js:332:11)
    at D:\Projets\MyApp\node_modules\electron-builder\src\packager.ts:186:52
    at next (native)
    at runCallback (timers.js:666:20)
    at tryOnImmediate (timers.js:639:5)
    at processImmediate [as _immediateCallback] (timers.js:611:5)
From previous event:
    at Packager.build (D:\Projets\MyApp\node_modules\electron-builder\out\packager.js:261:11)
    at D:\Projets\MyApp\node_modules\electron-builder\src\builder.ts:283:40
    at next (native)
From previous event:
    at build (D:\Projets\MyApp\node_modules\electron-builder\out\builder.js:63:21)
    at Object.<anonymous> (D:\Projets\MyApp\bin\deploy\deploy-electron\deploy-electron.js:80:28)
    at Module._compile (module.js:570:32)
    at loader (D:\Projets\MyApp\node_modules\babel-register\lib\node.js:144:5)
    at Object.require.extensions.(anonymous function) [as .js] (D:\Projets\MyApp\node_modules\babel-register\lib\node.js:154:7)
    at Module.load (module.js:487:32)
    at tryModuleLoad (module.js:446:12)
    at Function.Module._load (module.js:438:3)
    at Module.require (module.js:497:17)
    at require (internal/module.js:20:19)
    at Object.<anonymous> (D:\Projets\MyApp\bin\deploy\deploy-electron\index.js:2:1)
    at Module._compile (module.js:570:32)
    at Object.Module._extensions..js (module.js:579:10)
    at Module.load (module.js:487:32)
    at tryModuleLoad (module.js:446:12)
    at Function.Module._load (module.js:438:3)
    at Module.runMain (module.js:604:10)
    at run (bootstrap_node.js:393:7)
    at startup (bootstrap_node.js:150:9)

I try on another computer with Windows 7 and I have the same problem. But when I try on a computer with Windows 10, it works like a charm.

Again Thank you for this wonderful project!

develar commented 7 years ago

Strange, we provide special version of sign tool for win7 but is not used in your case. I will check why soon.

develar commented 7 years ago

@SJ-AW Please node -e "console.log(require('os').release())" on your windows 7 machine.

SJ-AW commented 7 years ago

@develar 6.1.7601