From 2860d132fc837813627e6508e05b18ed5e5dedfc Mon Sep 17 00:00:00 2001 From: Jimmy Lee Date: Mon, 2 May 2022 06:34:32 +0800 Subject: [PATCH] fix: incompatible Windows sign tool in end user environment. (#6817) * unify locate logic of windows signtool path side-effect: accept env variable SIGNTOOL_PATH for end-user customization. E.g. electron-builder bundle signtool.exe failed to sign in Windows 11 environment --- .changeset/quiet-pandas-cover.md | 5 +++++ packages/app-builder-lib/src/codeSign/windowsCodeSign.ts | 9 ++++----- 2 files changed, 9 insertions(+), 5 deletions(-) create mode 100644 .changeset/quiet-pandas-cover.md diff --git a/.changeset/quiet-pandas-cover.md b/.changeset/quiet-pandas-cover.md new file mode 100644 index 0000000000..da2d017f38 --- /dev/null +++ b/.changeset/quiet-pandas-cover.md @@ -0,0 +1,5 @@ +--- +"app-builder-lib": patch +--- + +fix: incompatible Windows sign tool in end user environment. Unify code logic to give end-user a chance to assign correct signtool.exe path with environment variable diff --git a/packages/app-builder-lib/src/codeSign/windowsCodeSign.ts b/packages/app-builder-lib/src/codeSign/windowsCodeSign.ts index a245a34af5..af531a052a 100644 --- a/packages/app-builder-lib/src/codeSign/windowsCodeSign.ts +++ b/packages/app-builder-lib/src/codeSign/windowsCodeSign.ts @@ -145,19 +145,18 @@ export async function getCertificateFromStoreInfo(options: WindowsConfiguration, export async function doSign(configuration: CustomWindowsSignTaskConfiguration, packager: WinPackager) { // https://github.com/electron-userland/electron-builder/pull/1944 const timeout = parseInt(process.env.SIGNTOOL_TIMEOUT as any, 10) || 10 * 60 * 1000 - - let tool: string + // unify logic of signtool path location + const toolInfo = await getToolPath() + const tool = toolInfo.path + // decide runtime argument by cases let args: Array let env = process.env let vm: VmManager if (configuration.path.endsWith(".appx") || !("file" in configuration.cscInfo!) /* certificateSubjectName and other such options */) { vm = await packager.vm.value - tool = getWinSignTool(await getSignVendorPath()) args = computeSignToolArgs(configuration, true, vm) } else { vm = new VmManager() - const toolInfo = await getToolPath() - tool = toolInfo.path args = configuration.computeSignToolArgs(process.platform === "win32") if (toolInfo.env != null) { env = toolInfo.env