app-builder-lib 27.0.0-alpha.14 → 27.0.0-alpha.15
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/codeSign/win/hsmSignManager.d.ts.map +1 -1
- package/dist/codeSign/win/hsmSignManager.js +3 -2
- package/dist/codeSign/win/hsmSignManager.js.map +1 -1
- package/dist/codeSign/win/pkcs11SignManager.d.ts.map +1 -1
- package/dist/codeSign/win/pkcs11SignManager.js +2 -1
- package/dist/codeSign/win/pkcs11SignManager.js.map +1 -1
- package/dist/codeSign/win/signtoolBaseSignManager.d.ts.map +1 -1
- package/dist/codeSign/win/signtoolBaseSignManager.js +15 -5
- package/dist/codeSign/win/signtoolBaseSignManager.js.map +1 -1
- package/dist/configuration.d.ts +36 -24
- package/dist/configuration.d.ts.map +1 -1
- package/dist/configuration.js.map +1 -1
- package/dist/indexInternal.d.ts +5 -3
- package/dist/indexInternal.d.ts.map +1 -1
- package/dist/indexInternal.js +4 -3
- package/dist/indexInternal.js.map +1 -1
- package/dist/options/FileAssociation.d.ts +1 -1
- package/dist/options/FileAssociation.js.map +1 -1
- package/dist/options/SnapOptions.d.ts +13 -3
- package/dist/options/SnapOptions.d.ts.map +1 -1
- package/dist/options/SnapOptions.js.map +1 -1
- package/dist/options/macOptions.d.ts +9 -6
- package/dist/options/macOptions.d.ts.map +1 -1
- package/dist/options/macOptions.js.map +1 -1
- package/dist/options/winOptions.d.ts +2 -2
- package/dist/options/winOptions.js.map +1 -1
- package/dist/packager.d.ts +16 -0
- package/dist/packager.d.ts.map +1 -1
- package/dist/packager.js +102 -64
- package/dist/packager.js.map +1 -1
- package/dist/platformPackager.d.ts.map +1 -1
- package/dist/platformPackager.js +10 -8
- package/dist/platformPackager.js.map +1 -1
- package/dist/publish/PublishManager.d.ts +5 -0
- package/dist/publish/PublishManager.d.ts.map +1 -1
- package/dist/publish/PublishManager.js +102 -24
- package/dist/publish/PublishManager.js.map +1 -1
- package/dist/publish/manifestUploadCheck.d.ts +12 -0
- package/dist/publish/manifestUploadCheck.d.ts.map +1 -1
- package/dist/publish/manifestUploadCheck.js +84 -12
- package/dist/publish/manifestUploadCheck.js.map +1 -1
- package/dist/publish/updateInfoBuilder.d.ts.map +1 -1
- package/dist/publish/updateInfoBuilder.js +5 -2
- package/dist/publish/updateInfoBuilder.js.map +1 -1
- package/dist/publish/updateManifestVerifier.d.ts +54 -0
- package/dist/publish/updateManifestVerifier.d.ts.map +1 -1
- package/dist/publish/updateManifestVerifier.js +121 -1
- package/dist/publish/updateManifestVerifier.js.map +1 -1
- package/dist/publish/updaterSettingsCheck.d.ts +8 -0
- package/dist/publish/updaterSettingsCheck.d.ts.map +1 -0
- package/dist/publish/updaterSettingsCheck.js +136 -0
- package/dist/publish/updaterSettingsCheck.js.map +1 -0
- package/dist/targets/ArchiveTarget.js +1 -1
- package/dist/targets/ArchiveTarget.js.map +1 -1
- package/dist/targets/archive.d.ts.map +1 -1
- package/dist/targets/archive.js +4 -3
- package/dist/targets/archive.js.map +1 -1
- package/dist/targets/linux/FlatpakTarget.js +1 -1
- package/dist/targets/linux/FlatpakTarget.js.map +1 -1
- package/dist/targets/linux/FpmTarget.d.ts.map +1 -1
- package/dist/targets/linux/FpmTarget.js +8 -30
- package/dist/targets/linux/FpmTarget.js.map +1 -1
- package/dist/targets/linux/LinuxTargetHelper.d.ts.map +1 -1
- package/dist/targets/linux/LinuxTargetHelper.js +6 -14
- package/dist/targets/linux/LinuxTargetHelper.js.map +1 -1
- package/dist/targets/linux/appimage/appLauncher.d.ts +4 -3
- package/dist/targets/linux/appimage/appLauncher.d.ts.map +1 -1
- package/dist/targets/linux/appimage/appLauncher.js +10 -6
- package/dist/targets/linux/appimage/appLauncher.js.map +1 -1
- package/dist/targets/linux/snap/coreLegacy.d.ts +8 -0
- package/dist/targets/linux/snap/coreLegacy.d.ts.map +1 -1
- package/dist/targets/linux/snap/coreLegacy.js +42 -9
- package/dist/targets/linux/snap/coreLegacy.js.map +1 -1
- package/dist/targets/mac/pkg.d.ts.map +1 -1
- package/dist/targets/mac/pkg.js +13 -9
- package/dist/targets/mac/pkg.js.map +1 -1
- package/dist/targets/targetFactory.d.ts +22 -3
- package/dist/targets/targetFactory.d.ts.map +1 -1
- package/dist/targets/targetFactory.js +59 -40
- package/dist/targets/targetFactory.js.map +1 -1
- package/dist/targets/win/MsiTarget.js +2 -2
- package/dist/targets/win/MsiTarget.js.map +1 -1
- package/dist/targets/win/nsis/Defines.d.ts +1 -0
- package/dist/targets/win/nsis/Defines.d.ts.map +1 -1
- package/dist/targets/win/nsis/Defines.js.map +1 -1
- package/dist/targets/win/nsis/NsisTarget.d.ts +3 -0
- package/dist/targets/win/nsis/NsisTarget.d.ts.map +1 -1
- package/dist/targets/win/nsis/NsisTarget.js +19 -6
- package/dist/targets/win/nsis/NsisTarget.js.map +1 -1
- package/dist/targets/win/nsis/nsisLicense.d.ts.map +1 -1
- package/dist/targets/win/nsis/nsisLicense.js +8 -5
- package/dist/targets/win/nsis/nsisLicense.js.map +1 -1
- package/dist/targets/win/nsis/nsisOptions.d.ts +31 -3
- package/dist/targets/win/nsis/nsisOptions.d.ts.map +1 -1
- package/dist/targets/win/nsis/nsisOptions.js.map +1 -1
- package/dist/targets/win/nsis/nsisScriptGenerator.d.ts +6 -0
- package/dist/targets/win/nsis/nsisScriptGenerator.d.ts.map +1 -1
- package/dist/targets/win/nsis/nsisScriptGenerator.js +16 -5
- package/dist/targets/win/nsis/nsisScriptGenerator.js.map +1 -1
- package/dist/targets/win/nsis/nsisUtil.d.ts.map +1 -1
- package/dist/targets/win/nsis/nsisUtil.js +11 -29
- package/dist/targets/win/nsis/nsisUtil.js.map +1 -1
- package/dist/toolsets/7zip.d.ts +10 -0
- package/dist/toolsets/7zip.d.ts.map +1 -1
- package/dist/toolsets/7zip.js +12 -1
- package/dist/toolsets/7zip.js.map +1 -1
- package/dist/toolsets/appimage.d.ts +2 -2
- package/dist/toolsets/appimage.js +3 -3
- package/dist/toolsets/appimage.js.map +1 -1
- package/dist/toolsets/archive.d.ts +13 -0
- package/dist/toolsets/archive.d.ts.map +1 -0
- package/dist/toolsets/archive.js +55 -0
- package/dist/toolsets/archive.js.map +1 -0
- package/dist/toolsets/custom.d.ts.map +1 -1
- package/dist/toolsets/custom.js +19 -2
- package/dist/toolsets/custom.js.map +1 -1
- package/dist/toolsets/fpm.d.ts +23 -0
- package/dist/toolsets/fpm.d.ts.map +1 -1
- package/dist/toolsets/fpm.js +52 -19
- package/dist/toolsets/fpm.js.map +1 -1
- package/dist/toolsets/nsis.d.ts +23 -4
- package/dist/toolsets/nsis.d.ts.map +1 -1
- package/dist/toolsets/nsis.js +49 -14
- package/dist/toolsets/nsis.js.map +1 -1
- package/dist/toolsets/winCodeSign.d.ts +20 -1
- package/dist/toolsets/winCodeSign.d.ts.map +1 -1
- package/dist/toolsets/winCodeSign.js +32 -5
- package/dist/toolsets/winCodeSign.js.map +1 -1
- package/dist/util/buildOutputVerifier.d.ts +2 -1
- package/dist/util/buildOutputVerifier.d.ts.map +1 -1
- package/dist/util/buildOutputVerifier.js +41 -63
- package/dist/util/buildOutputVerifier.js.map +1 -1
- package/dist/util/bundledTool.d.ts +8 -0
- package/dist/util/bundledTool.d.ts.map +1 -1
- package/dist/util/bundledTool.js +34 -0
- package/dist/util/bundledTool.js.map +1 -1
- package/dist/util/electronGet.d.ts.map +1 -1
- package/dist/util/electronGet.js +107 -10
- package/dist/util/electronGet.js.map +1 -1
- package/dist/util/electronUpdaterCompatibility.d.ts +21 -0
- package/dist/util/electronUpdaterCompatibility.d.ts.map +1 -1
- package/dist/util/electronUpdaterCompatibility.js +29 -0
- package/dist/util/electronUpdaterCompatibility.js.map +1 -1
- package/dist/util/flags.d.ts +5 -0
- package/dist/util/flags.d.ts.map +1 -1
- package/dist/util/flags.js +8 -2
- package/dist/util/flags.js.map +1 -1
- package/dist/util/mac/macosVersion.d.ts +0 -1
- package/dist/util/mac/macosVersion.d.ts.map +1 -1
- package/dist/util/mac/macosVersion.js +0 -21
- package/dist/util/mac/macosVersion.js.map +1 -1
- package/dist/util/packageMetadata.d.ts +14 -1
- package/dist/util/packageMetadata.d.ts.map +1 -1
- package/dist/util/packageMetadata.js +2 -2
- package/dist/util/packageMetadata.js.map +1 -1
- package/dist/util/removedEnvVars.js +1 -1
- package/dist/util/removedEnvVars.js.map +1 -1
- package/dist/version.d.ts +1 -1
- package/dist/version.js +1 -1
- package/dist/version.js.map +1 -1
- package/package.json +8 -8
- package/scheme.json +140 -46
- package/templates/nsis/assistedInstaller.nsh +5 -0
- package/templates/nsis/common.nsh +142 -1
- package/templates/nsis/include/installUtil.nsh +12 -0
- package/templates/nsis/include/installer.nsh +12 -0
- package/templates/nsis/installSection.nsh +3 -0
- package/templates/nsis/installer.nsi +25 -13
- package/templates/nsis/multiUser.nsh +50 -10
- package/templates/nsis/portable.nsi +1 -1
- package/templates/nsis/uninstaller.nsh +6 -0
- package/dist/toolsets/linuxToolsMac.d.ts +0 -8
- package/dist/toolsets/linuxToolsMac.d.ts.map +0 -1
- package/dist/toolsets/linuxToolsMac.js +0 -44
- package/dist/toolsets/linuxToolsMac.js.map +0 -1
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"hsmSignManager.d.ts","sourceRoot":"","sources":["../../../src/codeSign/win/hsmSignManager.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"hsmSignManager.d.ts","sourceRoot":"","sources":["../../../src/codeSign/win/hsmSignManager.ts"],"names":[],"mappings":"AAGA,OAAO,EAAE,SAAS,EAAE,MAAM,gBAAgB,CAAA;AAC1C,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,sBAAsB,CAAA;AACvD,OAAO,EAAE,iBAAiB,EAA2B,uBAAuB,EAAE,4BAA4B,EAAE,MAAM,8BAA8B,CAAA;AAEhJ,qBAAa,cAAe,SAAQ,uBAAuB;gBAC7C,QAAQ,EAAE,WAAW;cAQd,iBAAiB,CAAC,UAAU,EAAE,iBAAiB,GAAG,MAAM,GAAG,IAAI,GAAG,SAAS,GAAG,OAAO;IAOxG,SAAS,CAAC,sBAAsB,CAAC,OAAO,EAAE,4BAA4B,EAAE,EAAE,EAAE,SAAS,GAAG,KAAK,CAAC,MAAM,CAAC;IAsCrG,SAAS,CAAC,uBAAuB,CAAC,QAAQ,EAAE,4BAA4B,EAAE,GAAG,EAAE,SAAS,GAAG,KAAK,CAAC,MAAM,CAAC;CAKzG"}
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import { InvalidConfigurationError } from "builder-util";
|
|
2
2
|
import { resolveWindowsSigningConfiguration } from "../../options/winOptions.js";
|
|
3
|
+
import { isOfflineModeEnabled } from "../../util/flags.js";
|
|
3
4
|
import { getSigntoolFamilyConfig, SigntoolBaseSignManager } from "./signtoolBaseSignManager.js";
|
|
4
5
|
export class HsmSignManager extends SigntoolBaseSignManager {
|
|
5
6
|
constructor(packager) {
|
|
@@ -23,7 +24,7 @@ export class HsmSignManager extends SigntoolBaseSignManager {
|
|
|
23
24
|
const inputFile = vm.toVmFile(options.path);
|
|
24
25
|
const args = ["sign"];
|
|
25
26
|
// Timestamping
|
|
26
|
-
if (
|
|
27
|
+
if (!isOfflineModeEnabled()) {
|
|
27
28
|
const isRfc3161 = options.isNest || options.hash === "sha256";
|
|
28
29
|
args.push(isRfc3161 ? "/tr" : "/t");
|
|
29
30
|
args.push(isRfc3161 ? signing.rfc3161TimeStampServer || "http://timestamp.digicert.com" : signing.timeStampServer || "http://timestamp.digicert.com");
|
|
@@ -35,7 +36,7 @@ export class HsmSignManager extends SigntoolBaseSignManager {
|
|
|
35
36
|
args.push("/kc", signing.keyContainer);
|
|
36
37
|
// Modern toolset always requires /fd; no sha1 dual-sign path for HSM
|
|
37
38
|
args.push("/fd", options.hash.toLowerCase());
|
|
38
|
-
if (
|
|
39
|
+
if (!isOfflineModeEnabled() && (options.isNest || options.hash === "sha256")) {
|
|
39
40
|
args.push("/td", "sha256");
|
|
40
41
|
}
|
|
41
42
|
this.addCommonSigningArgs(args, options, vm, true);
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"hsmSignManager.js","sourceRoot":"","sources":["../../../src/codeSign/win/hsmSignManager.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,yBAAyB,EAAE,MAAM,cAAc,CAAA;AACxD,OAAO,EAAE,kCAAkC,EAA2B,MAAM,6BAA6B,CAAA;
|
|
1
|
+
{"version":3,"file":"hsmSignManager.js","sourceRoot":"","sources":["../../../src/codeSign/win/hsmSignManager.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,yBAAyB,EAAE,MAAM,cAAc,CAAA;AACxD,OAAO,EAAE,kCAAkC,EAA2B,MAAM,6BAA6B,CAAA;AACzG,OAAO,EAAE,oBAAoB,EAAE,MAAM,qBAAqB,CAAA;AAG1D,OAAO,EAAqB,uBAAuB,EAAE,uBAAuB,EAAgC,MAAM,8BAA8B,CAAA;AAEhJ,MAAM,OAAO,cAAe,SAAQ,uBAAuB;IACzD,YAAY,QAAqB;QAC/B,KAAK,CAAC,QAAQ,CAAC,CAAA;QACf,IAAI,kCAAkC,CAAC,QAAQ,CAAC,eAAe,CAAC,EAAE,IAAI,KAAK,KAAK,EAAE,CAAC;YACjF,MAAM,IAAI,KAAK,CAAC,8CAA8C,CAAC,CAAA;QACjE,CAAC;IACH,CAAC;IAED,0EAA0E;IACvD,iBAAiB,CAAC,UAAyD;QAC5F,IAAI,CAAC,UAAU,EAAE,CAAC;YAChB,MAAM,IAAI,yBAAyB,CAAC,wIAAwI,CAAC,CAAA;QAC/K,CAAC;QACD,OAAO,KAAK,CAAA;IACd,CAAC;IAES,sBAAsB,CAAC,OAAqC,EAAE,EAAa;QACnF,IAAI,IAAI,CAAC,eAAe,EAAE,EAAE,CAAC;YAC3B,MAAM,IAAI,yBAAyB,CACjC,yDAAyD,GAAG,wFAAwF,CACrJ,CAAA;QACH,CAAC;QAED,MAAM,OAAO,GAAG,uBAAuB,CAAC,OAAO,CAAC,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AAI,CAAC,QAAQ,CAAC,CAAA;QACnB,IAAI,CAAC,IAAI,CAAC,SAAS,CAAC,CAAA;QAEpB,OAAO,IAAI,CAAA;IACb,CAAC;IAES,uBAAuB,CAAC,QAAsC,EAAE,GAAc;QACtF,MAAM,IAAI,yBAAyB,CACjC,kGAAkG,GAAG,8CAA8C,CACpJ,CAAA;IACH,CAAC;CACF","sourcesContent":["import { InvalidConfigurationError } from \"builder-util\"\nimport { resolveWindowsSigningConfiguration, WindowsHsmSigningConfig } from \"../../options/winOptions.js\"\nimport { isOfflineModeEnabled } from \"../../util/flags.js\"\nimport { VmManager } from \"../../vm/vm.js\"\nimport type { WinPackager } from \"../../winPackager.js\"\nimport { CustomWindowsSign, getSigntoolFamilyConfig, SigntoolBaseSignManager, WindowsSignTaskConfiguration } from \"./signtoolBaseSignManager.js\"\n\nexport class HsmSignManager extends SigntoolBaseSignManager {\n constructor(packager: WinPackager) {\n super(packager)\n if (resolveWindowsSigningConfiguration(packager.platformOptions)?.type !== \"hsm\") {\n throw new Error(`HsmSignManager requires signing.type = \"hsm\"`)\n }\n }\n\n // HSM requires a certificate identifier; throw rather than silently skip.\n protected override handleNullCscInfo(customSign: CustomWindowsSign | string | null | undefined): boolean {\n if (!customSign) {\n throw new InvalidConfigurationError(\"HSM signing requires a certificate identifier. Provide certificateFile (e.g. a .crt/.pfx), certificateSha1, or certificateSubjectName.\")\n }\n return false\n }\n\n protected computeWindowsSignArgs(options: WindowsSignTaskConfiguration, vm: VmManager): Array<string> {\n if (this.isLegacyToolset()) {\n throw new InvalidConfigurationError(\n \"HSM signing requires winCodeSign toolset 1.x or later. \" + 'Set toolsets.winCodeSign to \"1.0.0\" or \"1.1.0\" in your electron-builder configuration.'\n )\n }\n\n const signing = getSigntoolFamilyConfig(options.options) as WindowsHsmSigningConfig\n const inputFile = vm.toVmFile(options.path)\n const args = [\"sign\"]\n\n // Timestamping\n if (!isOfflineModeEnabled()) {\n const isRfc3161 = options.isNest || options.hash === \"sha256\"\n args.push(isRfc3161 ? \"/tr\" : \"/t\")\n args.push(isRfc3161 ? signing.rfc3161TimeStampServer || \"http://timestamp.digicert.com\" : signing.timeStampServer || \"http://timestamp.digicert.com\")\n }\n\n // .crt/.cer allowed: public chain only, private key lives in the HSM.\n this.addCertificateArgs(args, options, vm, true, true)\n\n // HSM: /csp and /kc immediately after certificate identification\n args.push(\"/csp\", signing.cryptoServiceProvider)\n args.push(\"/kc\", signing.keyContainer)\n\n // Modern toolset always requires /fd; no sha1 dual-sign path for HSM\n args.push(\"/fd\", options.hash.toLowerCase())\n if (!isOfflineModeEnabled() && (options.isNest || options.hash === \"sha256\")) {\n args.push(\"/td\", \"sha256\")\n }\n\n this.addCommonSigningArgs(args, options, vm, true)\n args.push(\"/debug\")\n args.push(inputFile)\n\n return args\n }\n\n protected computeOsslsigncodeArgs(_options: WindowsSignTaskConfiguration, _vm: VmManager): Array<string> {\n throw new InvalidConfigurationError(\n \"HSM signing via cryptoServiceProvider/keyContainer is only supported on Windows (signtool.exe). \" + 'For macOS/Linux, use type: \"pkcs11\" instead.'\n )\n }\n}\n"]}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"pkcs11SignManager.d.ts","sourceRoot":"","sources":["../../../src/codeSign/win/pkcs11SignManager.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,QAAQ,EAAE,MAAM,sBAAsB,CAAA;AAC/C,OAAO,EAAsC,oBAAoB,EAA8B,MAAM,6BAA6B,CAAA;
|
|
1
|
+
{"version":3,"file":"pkcs11SignManager.d.ts","sourceRoot":"","sources":["../../../src/codeSign/win/pkcs11SignManager.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,QAAQ,EAAE,MAAM,sBAAsB,CAAA;AAC/C,OAAO,EAAsC,oBAAoB,EAA8B,MAAM,6BAA6B,CAAA;AAElI,OAAO,EAAE,SAAS,EAAE,MAAM,gBAAgB,CAAA;AAC1C,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,sBAAsB,CAAA;AACvD,OAAO,EACL,iBAAiB,EACjB,wBAAwB,EACxB,mBAAmB,EAEnB,uBAAuB,EACvB,4BAA4B,EAC7B,MAAM,8BAA8B,CAAA;AAErC,qBAAa,iBAAkB,SAAQ,uBAAuB;IAC5D,OAAO,CAAC,QAAQ,CAAC,aAAa,CAA4B;gBAE9C,QAAQ,EAAE,WAAW;IAuBjC,SAAkB,OAAO,wFAUxB;cAGkB,iBAAiB,CAAC,WAAW,EAAE,iBAAiB,GAAG,MAAM,GAAG,IAAI,GAAG,SAAS,GAAG,OAAO;IAIzG,SAAS,CAAC,sBAAsB,CAAC,QAAQ,EAAE,4BAA4B,EAAE,GAAG,EAAE,SAAS,GAAG,KAAK,CAAC,MAAM,CAAC;IAIvG,SAAS,CAAC,uBAAuB,CAAC,OAAO,EAAE,4BAA4B,EAAE,EAAE,EAAE,SAAS,GAAG,KAAK,CAAC,MAAM,CAAC;CAmDvG"}
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import { InvalidConfigurationError } from "builder-util";
|
|
2
2
|
import { MemoLazy } from "builder-util-runtime";
|
|
3
3
|
import { resolveWindowsSigningConfiguration } from "../../options/winOptions.js";
|
|
4
|
+
import { isOfflineModeEnabled } from "../../util/flags.js";
|
|
4
5
|
import { getSigntoolFamilyConfig, SigntoolBaseSignManager, } from "./signtoolBaseSignManager.js";
|
|
5
6
|
export class Pkcs11SignManager extends SigntoolBaseSignManager {
|
|
6
7
|
constructor(packager) {
|
|
@@ -48,7 +49,7 @@ export class Pkcs11SignManager extends SigntoolBaseSignManager {
|
|
|
48
49
|
options.resultOutputPath = outputPath;
|
|
49
50
|
const args = ["sign", "-in", inputFile, "-out", outputPath];
|
|
50
51
|
// RFC 3161 for sha256/nested (mirrors signtool /tr); HTTP Authenticode for sha1 (/t).
|
|
51
|
-
if (
|
|
52
|
+
if (!isOfflineModeEnabled()) {
|
|
52
53
|
const isRfc3161 = options.isNest || options.hash === "sha256";
|
|
53
54
|
if (isRfc3161) {
|
|
54
55
|
args.push("-ts", signing.rfc3161TimeStampServer || "http://timestamp.digicert.com");
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"pkcs11SignManager.js","sourceRoot":"","sources":["../../../src/codeSign/win/pkcs11SignManager.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,yBAAyB,EAAE,MAAM,cAAc,CAAA;AACxD,OAAO,EAAE,QAAQ,EAAE,MAAM,sBAAsB,CAAA;AAC/C,OAAO,EAAE,kCAAkC,EAAoD,MAAM,6BAA6B,CAAA;
|
|
1
|
+
{"version":3,"file":"pkcs11SignManager.js","sourceRoot":"","sources":["../../../src/codeSign/win/pkcs11SignManager.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,yBAAyB,EAAE,MAAM,cAAc,CAAA;AACxD,OAAO,EAAE,QAAQ,EAAE,MAAM,sBAAsB,CAAA;AAC/C,OAAO,EAAE,kCAAkC,EAAoD,MAAM,6BAA6B,CAAA;AAClI,OAAO,EAAE,oBAAoB,EAAE,MAAM,qBAAqB,CAAA;AAG1D,OAAO,EAIL,uBAAuB,EACvB,uBAAuB,GAExB,MAAM,8BAA8B,CAAA;AAErC,MAAM,OAAO,iBAAkB,SAAQ,uBAAuB;IAG5D,YAAY,QAAqB;QAC/B,KAAK,CAAC,QAAQ,CAAC,CAAA;QAoBjB,uFAAuF;QACvF,uGAAuG;QACrF,YAAO,GAAG,IAAI,QAAQ,CACtC,GAAG,EAAE,CAAC,IAAI,CAAC,4BAA4B,EACvC,6BAA6B,CAAC,EAAE;YAC9B,MAAM,EAAE,eAAe,EAAE,GAAG,IAAI,CAAC,aAAa,CAAA;YAC9C,IAAI,eAAe,EAAE,CAAC;gBACpB,MAAM,GAAG,GAAG,IAAI,CAAC,QAAQ,CAAC,cAAc,EAAE,IAAI,IAAI,CAAA;gBAClD,OAAO,OAAO,CAAC,OAAO,CAAC,EAAE,IAAI,EAAE,eAAe,EAAE,QAAQ,EAAE,GAAG,EAAE,CAAC,CAAA;YAClE,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,IAAI,EAAE,EAAE,CAAC;gBAChB,IAAI,CAAC,IAAI,CAAC,OAAO,EAAE,GAAG,CAAC,IAAI,EAAE,CAAC,CAAA;YAChC,CAAC;QACH,CAAC;QAED,MAAM,UAAU,GAAG,OAAO,CAAC,GAAG,CAAC,WAAW,CAAA;QAC1C,IAAI,UAAU,EAAE,MAAM,EAAE,CAAC;YACvB,IAAI,CAAC,IAAI,CAAC,IAAI,EAAE,UAAU,CAAC,CAAA;QAC7B,CAAC;QAED,OAAO,IAAI,CAAA;IACb,CAAC;CACF","sourcesContent":["import { InvalidConfigurationError } from \"builder-util\"\nimport { MemoLazy } from \"builder-util-runtime\"\nimport { resolveWindowsSigningConfiguration, WindowsConfiguration, WindowsPkcs11SigningConfig } from \"../../options/winOptions.js\"\nimport { isOfflineModeEnabled } from \"../../util/flags.js\"\nimport { VmManager } from \"../../vm/vm.js\"\nimport type { WinPackager } from \"../../winPackager.js\"\nimport {\n CustomWindowsSign,\n CertificateFromStoreInfo,\n FileCodeSigningInfo,\n getSigntoolFamilyConfig,\n SigntoolBaseSignManager,\n WindowsSignTaskConfiguration,\n} from \"./signtoolBaseSignManager.js\"\n\nexport class Pkcs11SignManager extends SigntoolBaseSignManager {\n private readonly signingConfig: WindowsPkcs11SigningConfig\n\n constructor(packager: WinPackager) {\n super(packager)\n const signing = resolveWindowsSigningConfiguration(packager.platformOptions)\n if (signing?.type !== \"pkcs11\") {\n throw new Error(`Pkcs11SignManager requires signing.type = \"pkcs11\", got: ${signing?.type}`)\n }\n this.signingConfig = signing\n\n // publisherName == null means \"auto-discover\", but for PKCS#11 without a certificateFile\n // the cert lives inside the hardware token and cannot be read at build time. The result would be\n // a null publisherName in app-update.yml, with which electron-updater 7 rejects every update.\n if (signing.publisherName == null && !signing.certificateFile) {\n throw new InvalidConfigurationError(\n \"PKCS#11 signing requires either `win.sign.publisherName` or `win.sign.certificateFile` to be set. \" +\n \"Without one of these the publisher name cannot be determined at build time, and electron-updater rejects every update of an app whose app-update.yml has no publisherName. \" +\n 'Set publisherName to the subject of your signing certificate, as a distinguished name (e.g. \"CN=My Company, O=My Company, C=US\"), ' +\n \"or provide certificateFile pointing to a certificate chain file (.crt / .cer).\"\n )\n }\n }\n\n // PKCS#11: key and cert are in the hardware token; cert file is optional (chain only).\n // When a cert file is supplied, the PIN (if any) is read from WIN_CSC_KEY_PASSWORD / CSC_KEY_PASSWORD.\n override readonly cscInfo = new MemoLazy<WindowsConfiguration, FileCodeSigningInfo | CertificateFromStoreInfo | null>(\n () => this.platformSpecificBuildOptions,\n _platformSpecificBuildOptions => {\n const { certificateFile } = this.signingConfig\n if (certificateFile) {\n const pin = this.packager.getCscPassword() ?? null\n return Promise.resolve({ file: certificateFile, password: pin })\n }\n return Promise.resolve(null)\n }\n )\n\n // PKCS#11: always proceed — the key URI is sufficient, no cert file required.\n protected override handleNullCscInfo(_customSign: CustomWindowsSign | string | null | undefined): boolean {\n return false\n }\n\n protected computeWindowsSignArgs(_options: WindowsSignTaskConfiguration, _vm: VmManager): Array<string> {\n throw new InvalidConfigurationError('PKCS#11 signing is only supported via osslsigncode (non-Windows). Use type: \"signtool\" or type: \"hsm\" on Windows.')\n }\n\n protected computeOsslsigncodeArgs(options: WindowsSignTaskConfiguration, vm: VmManager): Array<string> {\n const signing = getSigntoolFamilyConfig(options.options) as WindowsPkcs11SigningConfig\n\n // Runtime guard: JSON configs can produce partial objects that bypass TypeScript.\n if (!signing.pkcs11Module || !signing.pkcs11KeyUri) {\n throw new InvalidConfigurationError('pkcs11Module and pkcs11KeyUri must both be set for type: \"pkcs11\" signing.')\n }\n\n const inputFile = vm.toVmFile(options.path)\n const outputPath = this.getOutputPath(inputFile, options.hash)\n options.resultOutputPath = outputPath\n\n const args = [\"sign\", \"-in\", inputFile, \"-out\", outputPath]\n\n // RFC 3161 for sha256/nested (mirrors signtool /tr); HTTP Authenticode for sha1 (/t).\n if (!isOfflineModeEnabled()) {\n const isRfc3161 = options.isNest || options.hash === \"sha256\"\n if (isRfc3161) {\n args.push(\"-ts\", signing.rfc3161TimeStampServer || \"http://timestamp.digicert.com\")\n } else {\n args.push(\"-t\", signing.timeStampServer || \"http://timestamp.digicert.com\")\n }\n }\n\n args.push(\"-pkcs11module\", signing.pkcs11Module)\n args.push(\"-key\", signing.pkcs11KeyUri)\n\n // External certificate chain (optional — token may carry the cert internally).\n if (signing.certificateFile) {\n args.push(\"-certs\", vm.toVmFile(signing.certificateFile))\n }\n\n args.push(\"-h\", options.hash.toLowerCase())\n this.addCommonSigningArgs(args, options, vm, false)\n\n // When cscInfo is null the token holds the cert; addCommonSigningArgs won't emit -pass.\n // Read the PIN from env vars so CI workflows can inject it without embedding it in the URI.\n if (!options.cscInfo) {\n const pin = process.env.WIN_CSC_KEY_PASSWORD ?? process.env.CSC_KEY_PASSWORD\n if (pin?.trim()) {\n args.push(\"-pass\", pin.trim())\n }\n }\n\n const httpsProxy = process.env.HTTPS_PROXY\n if (httpsProxy?.length) {\n args.push(\"-p\", httpsProxy)\n }\n\n return args\n }\n}\n"]}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"signtoolBaseSignManager.d.ts","sourceRoot":"","sources":["../../../src/codeSign/win/signtoolBaseSignManager.ts"],"names":[],"mappings":"AACA,OAAO,EAAsB,QAAQ,EAA6C,MAAM,sBAAsB,CAAA;AAE9G,OAAO,EAAE,IAAI,EAAE,MAAM,UAAU,CAAA;AAE/B,OAAO,EAAE,MAAM,EAAE,MAAM,eAAe,CAAA;AACtC,OAAO,EAGL,oBAAoB,EAEpB,2BAA2B,EAE5B,MAAM,6BAA6B,CAAA;AAIpC,OAAO,
|
|
1
|
+
{"version":3,"file":"signtoolBaseSignManager.d.ts","sourceRoot":"","sources":["../../../src/codeSign/win/signtoolBaseSignManager.ts"],"names":[],"mappings":"AACA,OAAO,EAAsB,QAAQ,EAA6C,MAAM,sBAAsB,CAAA;AAE9G,OAAO,EAAE,IAAI,EAAE,MAAM,UAAU,CAAA;AAE/B,OAAO,EAA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,SAAS,CAAC,sBAAsB,CAAC,OAAO,EAAE,4BAA4B,EAAE,EAAE,EAAE,SAAS,GAAG,KAAK,CAAC,MAAM,CAAC;IA6CrG,SAAS,CAAC,uBAAuB,CAAC,OAAO,EAAE,4BAA4B,EAAE,EAAE,EAAE,SAAS,GAAG,KAAK,CAAC,MAAM,CAAC;CAgCvG;AAED;;;;;;;;;GASG;AACH,wBAAgB,4BAA4B,CAAC,QAAQ,EAAE,MAAM,EAAE,UAAU,EAAE,KAAK,CAAC,MAAM,GAAG,QAAQ,CAAC,GAAG,MAAM,GAAG,QAAQ,GAAG,IAAI,GAAG,SAAS,GAAG,KAAK,CAAC,MAAM,GAAG,QAAQ,CAAC,CAepK"}
|
|
@@ -7,6 +7,8 @@ import { isWindowsSigningDisabled, resolveWindowsSigningConfiguration, } from ".
|
|
|
7
7
|
import AppXTarget from "../../targets/win/AppxTarget.js";
|
|
8
8
|
import MsixTarget from "../../targets/win/MsixTarget.js";
|
|
9
9
|
import { getSignToolPath } from "../../toolsets/winCodeSign.js";
|
|
10
|
+
import { envWithoutPublishCredentials } from "../../util/bundledTool.js";
|
|
11
|
+
import { isOfflineModeEnabled } from "../../util/flags.js";
|
|
10
12
|
import { resolveFunction } from "../../util/resolve.js";
|
|
11
13
|
import { withSigntoolLock } from "../../util/toolsetLock.js";
|
|
12
14
|
import { readCertInfo, readCertInfoFromX509 } from "../certInfo.js";
|
|
@@ -307,6 +309,14 @@ export class SigntoolBaseSignManager {
|
|
|
307
309
|
}
|
|
308
310
|
// on windows be aware of http://stackoverflow.com/a/32640183/1910191
|
|
309
311
|
computeSignToolArgs(options, isWin, vm = new VmManager()) {
|
|
312
|
+
if (isOfflineModeEnabled()) {
|
|
313
|
+
log
|
|
314
|
+
.once("offline-skips-timestamp", options.cscInfo)
|
|
315
|
+
.warn(null, "ELECTRON_BUILDER_OFFLINE is set, so Windows signatures get no timestamp and stop validating once the signing certificate expires. " +
|
|
316
|
+
"ELECTRON_BUILDER_OFFLINE=1 skips the timestamp server the same as ELECTRON_BUILDER_OFFLINE=true. " +
|
|
317
|
+
"Unset ELECTRON_BUILDER_OFFLINE for release builds. " +
|
|
318
|
+
`See ${BUILD_CHANGES_URL}#electron_builder_offline-skips-the-signing-timestamp`);
|
|
319
|
+
}
|
|
310
320
|
return isWin ? this.computeWindowsSignArgs(options, vm) : this.computeOsslsigncodeArgs(options, vm);
|
|
311
321
|
}
|
|
312
322
|
isLegacyToolset() {
|
|
@@ -427,7 +437,7 @@ export class SigntoolBaseSignManager {
|
|
|
427
437
|
}
|
|
428
438
|
// signtool.exe (`/f`) is not safe to run concurrently — it races on the shared per-user crypto store.
|
|
429
439
|
// Serialize real-Windows signtool invocations across processes; osslsigncode (`!isWin`) is file-isolated.
|
|
430
|
-
const execSign = () => vm.exec(tool, args, { timeout, env:
|
|
440
|
+
const execSign = () => vm.exec(tool, args, { timeout, env: envWithoutPublishCredentials(toolInfo.env) });
|
|
431
441
|
await retry(() => (isWin ? withSigntoolLock(execSign) : execSign()), {
|
|
432
442
|
retries: 2,
|
|
433
443
|
interval: 15000,
|
|
@@ -453,7 +463,7 @@ export class SigntoolSignManager extends SigntoolBaseSignManager {
|
|
|
453
463
|
const inputFile = vm.toVmFile(options.path);
|
|
454
464
|
const args = ["sign"];
|
|
455
465
|
// Timestamping
|
|
456
|
-
if (
|
|
466
|
+
if (!isOfflineModeEnabled()) {
|
|
457
467
|
const isRfc3161 = options.isNest || options.hash === "sha256";
|
|
458
468
|
args.push(isRfc3161 ? "/tr" : "/t");
|
|
459
469
|
const timestampUrl = isRfc3161 ? signing?.rfc3161TimeStampServer || "http://timestamp.digicert.com" : signing?.timeStampServer || "http://timestamp.digicert.com";
|
|
@@ -466,7 +476,7 @@ export class SigntoolSignManager extends SigntoolBaseSignManager {
|
|
|
466
476
|
// Legacy v0.0.0: Only add /fd for non-SHA1 (original behavior)
|
|
467
477
|
if (options.hash !== "sha1") {
|
|
468
478
|
args.push("/fd", options.hash);
|
|
469
|
-
if (
|
|
479
|
+
if (!isOfflineModeEnabled()) {
|
|
470
480
|
args.push("/td", "sha256");
|
|
471
481
|
}
|
|
472
482
|
}
|
|
@@ -475,7 +485,7 @@ export class SigntoolSignManager extends SigntoolBaseSignManager {
|
|
|
475
485
|
// Modern: Always add /fd (required by new Windows Kits)
|
|
476
486
|
args.push("/fd", options.hash.toLowerCase());
|
|
477
487
|
// Only add /td for RFC3161 timestamps (incompatible with /t)
|
|
478
|
-
if (
|
|
488
|
+
if (!isOfflineModeEnabled() && (options.isNest || options.hash === "sha256")) {
|
|
479
489
|
args.push("/td", "sha256");
|
|
480
490
|
}
|
|
481
491
|
}
|
|
@@ -493,7 +503,7 @@ export class SigntoolSignManager extends SigntoolBaseSignManager {
|
|
|
493
503
|
options.resultOutputPath = outputPath;
|
|
494
504
|
const args = ["sign", "-in", inputFile, "-out", outputPath];
|
|
495
505
|
// Timestamping
|
|
496
|
-
if (
|
|
506
|
+
if (!isOfflineModeEnabled()) {
|
|
497
507
|
const timestampUrl = signing?.timeStampServer || "http://timestamp.digicert.com";
|
|
498
508
|
args.push("-t", timestampUrl);
|
|
499
509
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"signtoolBaseSignManager.js","sourceRoot":"","sources":["../../../src/codeSign/win/signtoolBaseSignManager.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,OAAO,EAAE,yBAAyB,EAAE,GAAG,EAAE,KAAK,EAAE,MAAM,cAAc,CAAA;AAC7E,OAAO,EAAE,kBAAkB,EAAE,QAAQ,EAAE,OAAO,EAAE,gCAAgC,EAAE,MAAM,sBAAsB,CAAA;AAC9G,OAAO,QAAQ,MAAM,UAAU,CAAA;AAC/B,OAAO,EAAE,IAAI,EAAE,MAAM,UAAU,CAAA;AAC/B,OAAO,KAAK,IAAI,MAAM,MAAM,CAAA;AAE5B,OAAO,EACL,wBAAwB,EACxB,kCAAkC,GAKnC,MAAM,6BAA6B,CAAA;AACpC,OAAO,UAAU,MAAM,iC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,OAAO,IAAI,CAAA;IACb,CAAC;CACF;AAED;;;;;;;;;GASG;AACH,MAAM,UAAU,4BAA4B,CAAC,QAAgB,EAAE,UAA2E;IACxI,MAAM,SAAS,GAAG,UAAU,IAAI,IAAI,CAAC,CAAC,CAAC,IAAI,CAAC,CAAC,CAAC,OAAO,CAAC,UAAU,CAAC,CAAA;IACjE,IAAI,SAAS,IAAI,IAAI,IAAI,SAAS,CAAC,MAAM,KAAK,CAAC,EAAE,CAAC;QAChD,MAAM,IAAI,yBAAyB,CACjC,uOAAuO,CACxO,CAAA;IACH,CAAC;IACD,MAAM,GAAG,GAAG,IAAI,CAAC,OAAO,CAAC,QAAQ,CAAC,CAAC,WAAW,EAAE,CAAA;IAChD,IAAI,GAAG,KAAK,MAAM,EAAE,CAAC;QACnB,OAAO,CAAC,SAAS,IAAI,IAAI,IAAI,CAAC,SAAS,CAAC,QAAQ,CAAC,QAAQ,CAAC,CAAC,CAAC,CAAC,MAAM,CAAC,CAAC,CAAC,QAAQ,CAAC,CAAA;IACjF,CAAC;IACD,IAAI,GAAG,KAAK,OAAO,IAAI,GAAG,KAAK,OAAO,IAAI,GAAG,KAAK,aAAa,EAAE,CAAC;QAChE,OAAO,CAAC,QAAQ,CAAC,CAAA;IACnB,CAAC;IACD,OAAO,SAAS,IAAI,CAAC,MAAM,EAAE,QAAQ,CAAC,CAAA;AACxC,CAAC","sourcesContent":["import { asArray, InvalidConfigurationError, log, retry } from \"builder-util\"\nimport { matchPublisherName, MemoLazy, parseDn, POWERSHELL_ASCII_ESCAPE_FUNCTION } from \"builder-util-runtime\"\nimport _fsExtra from \"fs-extra\"\nimport { Lazy } from \"lazy-val\"\nimport * as path from \"path\"\nimport { Target } from \"../../core.js\"\nimport {\n isWindowsSigningDisabled,\n resolveWindowsSigningConfiguration,\n WindowsConfiguration,\n WindowsHsmSigningConfig,\n WindowsSigntoolFamilyConfig,\n WindowsSigntoolSigningConfig,\n} from \"../../options/winOptions.js\"\nimport AppXTarget from \"../../targets/win/AppxTarget.js\"\nimport MsixTarget from \"../../targets/win/MsixTarget.js\"\nimport { getSignToolPath } from \"../../toolsets/winCodeSign.js\"\nimport { ToolInfo } from \"../../util/bundledTool.js\"\nimport { resolveFunction } from \"../../util/resolve.js\"\nimport { withSigntoolLock } from \"../../util/toolsetLock.js\"\nimport { readCertInfo, readCertInfoFromX509 } from \"../certInfo.js\"\nimport { VmManager } from \"../../vm/vm.js\"\nimport type { WinPackager } from \"../../winPackager.js\"\nimport { importCertificate } from \"../codesign.js\"\nimport { derivePublisherName, PUBLISHER_NAME_DN_DOCS_URL, validatePublisherNameFormat } from \"./publisherName.js\"\nimport type { SignManager } from \"./signManager.js\"\nimport { WindowsSignOptions } from \"./windowsCodeSign.js\"\nimport { SignFileResult } from \"../signResult.js\"\nimport { BUILD_CHANGES_URL } from \"../../util/config/legacyOptions.js\"\n\nconst PUBLISHER_NAME_DOCS = `${BUILD_CHANGES_URL}#windows-publishername-is-validated-against-the-signing-certificate`\nconst { rename } = _fsExtra\n\nexport type CustomWindowsSign = (configuration: CustomWindowsSignTaskConfiguration, packager?: WinPackager) => Promise<any>\n\nexport interface WindowsSignToolOptions extends WindowsSignOptions {\n readonly name: string\n readonly site: string | null\n}\n\nexport interface FileCodeSigningInfo {\n readonly file: string\n readonly password: string | null\n}\n\nexport interface WindowsSignTaskConfiguration extends WindowsSignToolOptions {\n readonly cscInfo: FileCodeSigningInfo | CertificateFromStoreInfo | null\n\n // set if output path differs from input (e.g. osslsigncode cannot sign file in-place)\n resultOutputPath?: string\n\n hash: string\n isNest: boolean\n}\n\nexport interface CustomWindowsSignTaskConfiguration extends WindowsSignTaskConfiguration {\n computeSignToolArgs(isWin: boolean): Array<string>\n}\n\nexport interface CertificateInfo {\n readonly commonName: string\n readonly bloodyMicrosoftSubjectDn: string\n /**\n * The subject in the format Windows reports it (`X509Certificate2.Subject`), which electron-updater matches\n * publisherName against. Unset when `bloodyMicrosoftSubjectDn` already is in that format (certificate store).\n */\n readonly windowsSubjectDn?: string\n}\n\nexport interface CertificateFromStoreInfo {\n thumbprint: string\n subject: string\n store: string\n isLocalMachineStore: boolean\n}\n\ninterface CertInfo {\n Subject: string\n Thumbprint: string\n PSParentPath: string\n}\n\n/** Extracts the non-Azure signing config from WindowsConfiguration, or null for Azure/unset/disabled. */\nexport function getSigntoolFamilyConfig(config: WindowsConfiguration): WindowsSigntoolFamilyConfig | null {\n const s = resolveWindowsSigningConfiguration(config)\n if (s == null || s.type === \"azure\") {\n return null\n }\n return s\n}\n\n/** The certificate subject in the format Windows reports it, which electron-updater matches publisherName against. */\nexport function certificateWindowsSubjectDn(certInfo: CertificateInfo): string {\n return certInfo.windowsSubjectDn ?? certInfo.bloodyMicrosoftSubjectDn\n}\n\n/**\n * Matches configured publisher names against a certificate subject with the matcher electron-updater's update\n * signature verifier uses ({@link matchPublisherName}): a name must be a Distinguished Name (DN), and every RDN it\n * specifies must equal the certificate subject's (extra subject RDNs are ignored). Passes when ANY\n * configured name matches — multiple names are supported for certificate rotation. The subject is taken in the format\n * Windows reports it (as the updater sees it).\n */\nexport function publisherNameMatchesCertificate(publisherNames: Array<string>, certInfo: CertificateInfo): boolean {\n // matchPublisherName takes the parsed Get-AuthenticodeSignature output, as electron-updater passes it\n return matchPublisherName({ SignerCertificate: { Subject: certificateWindowsSubjectDn(certInfo) } }, publisherNames)\n}\n\nexport abstract class SigntoolBaseSignManager implements SignManager {\n protected readonly platformSpecificBuildOptions: WindowsConfiguration\n\n constructor(protected readonly packager: WinPackager) {\n this.platformSpecificBuildOptions = packager.platformOptions\n }\n\n readonly computedPublisherName = new Lazy<Array<string> | null>(async () => {\n // `win.sign: false` / `null` signs nothing, so no publisherName is derived: a build that writes app-update.yml then needs\n // win.verifyUpdateCodeSignature: false (or a win.sign object with publisherName), see missingUpdatePublisherNameError.\n if (isWindowsSigningDisabled(this.platformSpecificBuildOptions)) {\n return null\n }\n\n const signing = getSigntoolFamilyConfig(this.platformSpecificBuildOptions)\n const publisherName = signing?.publisherName\n if (publisherName === null) {\n return null\n } else if (publisherName != null) {\n await this.explicitPublisherNameValidation.value\n return asArray(publisherName)\n }\n\n // A custom `sign` hook signs with a certificate electron-builder doesn't see (not even one named in the config is known to be the one\n // the hook uses), so the publisher name that electron-updater trusts must be configured explicitly.\n if (signing?.sign != null) {\n throw new InvalidConfigurationError(\n \"A custom Windows signing hook (`win.sign.sign`) is configured without `win.sign.publisherName`. \" +\n \"electron-builder cannot tell which certificate the hook signs with, and electron-updater verifies the signature of downloaded updates against the publisherName in app-update.yml. \" +\n 'Set `win.sign.publisherName` to the subject of the certificate that your hook signs with, as a distinguished name (e.g. \"CN=My Company, O=My Company, C=US\"), ' +\n \"or set `win.verifyUpdateCodeSignature: false` (only if your updates are not Authenticode-signed or you don't use electron-updater) to opt out of update signature verification explicitly. \" +\n `See ${PUBLISHER_NAME_DOCS}`\n )\n }\n\n const certInfo = await this.lazyCertInfo.value\n if (certInfo?.commonName) {\n // `CN=<common name>`, quoted as Windows reports the signer subject (which electron-updater 7 matches against): pinning only the CN\n // keeps updates working across a certificate renewal that changes other subject attributes. A stricter pin is an explicit publisherName.\n return [derivePublisherName(certInfo.commonName)]\n }\n // Signed with a certificate without a CN (or whose subject cannot be read): electron-updater verifies downloaded updates against the\n // publisherName in app-update.yml, so the build needs one.\n if ((await this.cscInfo.value) != null) {\n throw new InvalidConfigurationError(\n \"Windows code signing is configured, but the publisher name cannot be determined at build time (the signing certificate has no Common Name). \" +\n \"electron-updater verifies the signature of downloaded updates against the publisherName in app-update.yml. \" +\n 'Set `win.sign.publisherName` to the subject of the certificate that signs your app, as a distinguished name (e.g. \"CN=My Company, O=My Company, C=US\"), ' +\n \"or set `win.verifyUpdateCodeSignature: false` (only if your updates are not Authenticode-signed or you don't use electron-updater) to opt out of update signature verification explicitly. \" +\n `See ${PUBLISHER_NAME_DN_DOCS_URL}`\n )\n }\n return null\n })\n\n readonly lazyCertInfo = new MemoLazy<MemoLazy<WindowsConfiguration, FileCodeSigningInfo | CertificateFromStoreInfo | null>, CertificateInfo | null>(\n () => this.cscInfo,\n async csc => {\n const cscInfo = await csc.value\n if (cscInfo == null) {\n return null\n }\n\n if (\"subject\" in cscInfo) {\n const bloodyMicrosoftSubjectDn = cscInfo.subject\n return {\n // empty for a subject without a CN, like readCertInfo, so computedPublisherName requires an explicit publisherName\n commonName: parseDn(bloodyMicrosoftSubjectDn).get(\"CN\") ?? \"\",\n // read from the Windows certificate store, so already in the format Windows reports (windowsSubjectDn falls back to it)\n bloodyMicrosoftSubjectDn,\n }\n }\n\n const cscFile = cscInfo.file\n if (cscFile == null) {\n return null\n }\n\n const certExt = path.extname(cscFile).toLowerCase()\n if (certExt === \".p12\" || certExt === \".pfx\") {\n return await this.getCertInfo(cscFile, cscInfo.password || \"\")\n }\n // Non-PKCS12 files (.crt, .cer): parse as plain X.509.\n // Returns null when the CN is absent — caller must set publisherName explicitly.\n return await readCertInfoFromX509(cscFile)\n }\n )\n\n // Memoized so the check runs once per build even though signFile is invoked once per file.\n private readonly explicitPublisherNameValidation = new Lazy<void>(() => this.validateExplicitPublisherName())\n\n /**\n * When `publisherName` is explicitly configured, fail the build if an entry is not a distinguished name\n * (electron-updater 7 never matches one), whatever the signing route. Then, when the subject of the local code\n * signing certificate is known, fail the build if none of the configured names match the certificate.\n * This catches signing with the wrong certificate at build time — otherwise the mismatch only\n * surfaces at update time, when electron-updater rejects every update signed with that\n * certificate.\n *\n * The check is intentionally skipped whenever the actual signing certificate's subject is not\n * genuinely known: custom `sign` hooks, PKCS#11 without an extractable certificate file,\n * x509 certificate files without a CN, or any error while reading certificate info.\n * An explicit `publisherName: null` has nothing to validate (a build that writes `app-update.yml` with it fails in PublishManager).\n */\n protected async validateExplicitPublisherName(): Promise<void> {\n const signing = getSigntoolFamilyConfig(this.platformSpecificBuildOptions)\n const publisherName = signing?.publisherName\n if (publisherName == null) {\n // not configured (auto-derive) or explicit `null` (no opt-out any more: rejected where app-update.yml is written) — nothing to validate\n return\n }\n validatePublisherNameFormat(publisherName)\n if (signing?.sign != null) {\n // custom sign hook: electron-builder does not know which certificate the hook actually signs with\n return\n }\n const publisherNames = asArray(publisherName)\n if (publisherNames.length === 0) {\n return\n }\n\n let certInfo: CertificateInfo | null\n try {\n certInfo = await this.lazyCertInfo.value\n } catch (e: any) {\n // this check must only fire when the signing certificate's subject is genuinely known\n log.debug({ error: e.message || e }, \"skipping publisherName validation against the signing certificate (cannot read certificate info)\")\n return\n }\n if (certInfo == null) {\n return\n }\n\n if (!publisherNameMatchesCertificate(publisherNames, certInfo)) {\n throw new InvalidConfigurationError(\n `The configured publisherName does not match the subject of the code signing certificate. ` +\n `This usually means the build is signing with the wrong certificate (for example, a code signing certificate for another platform or team leaked into WIN_CSC_LINK/CSC_LINK in CI) — electron-updater would reject every update signed with it.\\n` +\n ` Configured publisherName: ${publisherNames.join(\" | \")}\\n` +\n ` Certificate subject: ${certificateWindowsSubjectDn(certInfo)}\\n` +\n `Fix win.sign.publisherName (or sign with the intended certificate). To opt out of update signature verification entirely, set win.verifyUpdateCodeSignature: false.`\n )\n }\n }\n\n readonly cscInfo = new MemoLazy<WindowsConfiguration, FileCodeSigningInfo | CertificateFromStoreInfo | null>(\n () => this.platformSpecificBuildOptions,\n platformSpecificBuildOptions => {\n // `win.sign: false` / `null` signs nothing: no certificate is read (not even from CSC_LINK / WIN_CSC_LINK), so none\n // supplies an AppX/MSIX publisher, a publisherName for app-update.yml or a build-cache digest.\n if (isWindowsSigningDisabled(platformSpecificBuildOptions)) {\n return Promise.resolve(null)\n }\n const signing = getSigntoolFamilyConfig(platformSpecificBuildOptions)\n // signtool is the implicit default when win.sign is unset, so an absent config still\n // honours the WIN_CSC_LINK/cscLink fallback below (hsm/pkcs11 set signing.type explicitly).\n const isSigntool = signing == null || signing.type === \"signtool\"\n\n // signtool + hsm: store-based cert takes priority\n const subjectName = (signing as WindowsSigntoolSigningConfig | WindowsHsmSigningConfig | null)?.certificateSubjectName\n const shaType = (signing as WindowsSigntoolSigningConfig | WindowsHsmSigningConfig | null)?.certificateSha1\n if (subjectName != null || shaType != null) {\n return this.packager.vm.value\n .then(vm => this.getCertificateFromStoreInfo(platformSpecificBuildOptions, vm))\n .catch((e: any) => {\n // https://github.com/electron-userland/electron-builder/pull/2397\n if (signing?.sign == null) {\n throw e\n } else {\n log.debug({ error: e }, \"getCertificateFromStoreInfo error\")\n return null\n }\n })\n }\n\n const certificateFile = signing?.certificateFile\n if (certificateFile != null) {\n // Only signtool mode uses a password (HSM private key lives in the HSM, not the cert file)\n const certificatePassword = isSigntool ? this.packager.getCscPassword() : null\n return Promise.resolve({\n file: certificateFile,\n password: certificatePassword == null ? null : certificatePassword.trim(),\n })\n }\n\n // WIN_CSC_LINK env var fallback: only for signtool mode (including the implicit default)\n if (isSigntool) {\n const cscLink = this.packager.getCscLink(\"WIN_CSC_LINK\")\n if (cscLink == null || cscLink === \"\") {\n return Promise.resolve(null)\n }\n\n return importCertificate(cscLink, this.packager.tempDirManager, this.packager.projectDir)\n .catch((e: any) => {\n if (e instanceof InvalidConfigurationError) {\n throw new InvalidConfigurationError(`Env WIN_CSC_LINK is not correct, cannot resolve: ${e.message}`)\n } else {\n throw e\n }\n })\n .then(p => ({\n file: p,\n password: this.packager.getCscPassword(),\n }))\n }\n\n return Promise.resolve(null)\n }\n )\n\n initialize(): Promise<void> {\n return Promise.resolve()\n }\n\n // https://github.com/electron-userland/electron-builder/issues/2108#issuecomment-333200711\n async computePublisherName(target: Target, publisherName: string | null) {\n if ((target instanceof AppXTarget || target instanceof MsixTarget) && (await this.cscInfo.value) == null) {\n log.info({ reason: \"Windows Store only build\" }, \"AppX/MSIX package is not signed\")\n return publisherName ?? \"CN=ms\"\n }\n\n // When a signing cert is available, the cert's subject MUST be used so the APPX package\n // Publisher attribute matches the certificate — any mismatch causes SignerSign to fail with\n // ERROR_BAD_FORMAT. Only honour a user-supplied publisherName if it was explicitly configured\n // (non-null); otherwise derive from the certificate. The subject is written in the format Windows reports it\n // (`, `-separated, Windows attribute names such as S): MakeAppx rejects a multi-RDN Publisher separated by a bare `,`\n // or using the OpenSSL name ST.\n const certInfo = await this.lazyCertInfo.value\n const publisher = publisherName ?? (certInfo == null ? null : certificateWindowsSubjectDn(certInfo))\n if (publisher == null) {\n throw new Error(\"Internal error: cannot compute subject using certificate info\")\n }\n return publisher\n }\n\n /**\n * Called when cscInfo is null. Returns true to skip signing, false to proceed, or throws.\n * Override in subclasses with different null-cert behaviour (HSM throws, PKCS#11 proceeds).\n */\n protected handleNullCscInfo(customSign: CustomWindowsSign | string | null | undefined): boolean {\n return !customSign // default: skip when no cert and no custom sign hook\n }\n\n async signFile(options: WindowsSignOptions): Promise<SignFileResult> {\n const signing = getSigntoolFamilyConfig(options.options)\n const hashes = resolveSigningHashAlgorithms(options.path, signing?.signingHashAlgorithms)\n\n const name = this.packager.appInfo.productName\n const site = await this.packager.appInfo.computePackageUrl()\n\n const customSign = await resolveFunction(this.packager.appInfo.type, signing?.sign, \"sign\", await this.packager.getWorkspaceRoot())\n\n const cscInfo = await this.cscInfo.value\n\n if (cscInfo) {\n let logInfo: any = {\n file: log.filePath(options.path),\n }\n if (\"file\" in cscInfo) {\n logInfo = { ...logInfo, certificateFile: cscInfo.file }\n } else {\n logInfo = {\n ...logInfo,\n subject: cscInfo.subject,\n thumbprint: cscInfo.thumbprint,\n store: cscInfo.store,\n user: cscInfo.isLocalMachineStore ? \"local machine\" : \"current user\",\n }\n }\n log.info(logInfo, \"signing\")\n } else if (this.handleNullCscInfo(customSign)) {\n // the canonical \"signing skipped\" message is logged once in signWindows, which receives this reason\n return \"skipped:no-certificate\"\n }\n // validate an explicitly configured publisherName (its format on every signing route, and against the signing certificate when\n // known) before the first file is signed, so a wrong-certificate build fails even when no publish config exists\n await this.explicitPublisherNameValidation.value\n\n const executor = customSign || ((config: CustomWindowsSignTaskConfiguration, packager: WinPackager) => this.doSign(config, packager))\n let isNest = false\n for (const hash of hashes) {\n const taskConfiguration: WindowsSignTaskConfiguration = { ...options, name, site, cscInfo, hash, isNest }\n await Promise.resolve(\n executor(\n {\n ...taskConfiguration,\n computeSignToolArgs: isWin => this.computeSignToolArgs(taskConfiguration, isWin),\n },\n this.packager\n )\n )\n isNest = true\n if (taskConfiguration.resultOutputPath != null) {\n await rename(taskConfiguration.resultOutputPath, options.path)\n }\n }\n\n return customSign ? \"signed:custom\" : \"signed\"\n }\n\n async getCertInfo(file: string, password: string): Promise<CertificateInfo> {\n const errorMessagePrefix = \"Cannot extract publisher name from code signing certificate. As workaround, set win.sign.publisherName. Error: \"\n try {\n return await readCertInfo(file, password)\n } catch (e: any) {\n throw new InvalidConfigurationError(`${errorMessagePrefix}${e.message || e}`)\n }\n }\n\n // on windows be aware of http://stackoverflow.com/a/32640183/1910191\n computeSignToolArgs(options: WindowsSignTaskConfiguration, isWin: boolean, vm: VmManager = new VmManager()): Array<string> {\n return isWin ? this.computeWindowsSignArgs(options, vm) : this.computeOsslsigncodeArgs(options, vm)\n }\n\n protected isLegacyToolset(): boolean {\n const v = this.packager.config.toolsets?.winCodeSign\n // Only an explicit \"0.0.0\" pin is legacy; unset / null / \"latest\" / custom now resolve to a modern bundle.\n return v === \"0.0.0\"\n }\n\n protected abstract computeWindowsSignArgs(options: WindowsSignTaskConfiguration, vm: VmManager): Array<string>\n protected abstract computeOsslsigncodeArgs(options: WindowsSignTaskConfiguration, vm: VmManager): Array<string>\n\n // allowX509: set to true by HsmSignManager to permit .crt/.cer (public chain only, key is in HSM).\n protected addCertificateArgs(args: Array<string>, options: WindowsSignTaskConfiguration, vm: VmManager, isWin: boolean, allowX509 = false): void {\n if (options.cscInfo == null) {\n throw new Error(\"No code signing certificate configured. Provide certificateFile, certificateSha1, or certificateSubjectName.\")\n }\n const certificateFile = (options.cscInfo as FileCodeSigningInfo).file\n\n if (certificateFile == null) {\n // Certificate from store (Windows only)\n if (!isWin) {\n throw new Error(\"certificateSha1/certificateSubjectName supported only on Windows\")\n }\n\n const cscInfo = options.cscInfo as CertificateFromStoreInfo\n args.push(\"/sha1\", cscInfo.thumbprint)\n args.push(\"/s\", cscInfo.store)\n if (cscInfo.isLocalMachineStore) {\n args.push(\"/sm\")\n }\n } else {\n const certExtension = path.extname(certificateFile).toLowerCase()\n\n if (certExtension === \".p12\" || certExtension === \".pfx\") {\n args.push(isWin ? \"/f\" : \"-pkcs12\", vm.toVmFile(certificateFile))\n } else if (isWin && allowX509 && (certExtension === \".crt\" || certExtension === \".cer\")) {\n args.push(\"/f\", vm.toVmFile(certificateFile))\n } else {\n throw new InvalidConfigurationError(`Please specify pkcs12 (.p12/.pfx) file, ${certificateFile} is not correct`)\n }\n }\n }\n\n protected addCommonSigningArgs(args: Array<string>, options: WindowsSignTaskConfiguration, vm: VmManager, isWin: boolean): void {\n if (options.name) {\n args.push(isWin ? \"/d\" : \"-n\", options.name)\n }\n\n if (options.site) {\n args.push(isWin ? \"/du\" : \"-i\", options.site)\n }\n\n if (options.isNest) {\n args.push(isWin ? \"/as\" : \"-nest\")\n }\n\n const password = (options.cscInfo as FileCodeSigningInfo)?.password\n if (password) {\n args.push(isWin ? \"/p\" : \"-pass\", password)\n }\n\n const signing = getSigntoolFamilyConfig(options.options)\n const additionalCert = signing?.additionalCertificateFile\n if (additionalCert) {\n args.push(isWin ? \"/ac\" : \"-ac\", vm.toVmFile(additionalCert))\n }\n }\n\n getOutputPath(inputPath: string, hash: string) {\n const extension = path.extname(inputPath)\n return path.join(path.dirname(inputPath), `${path.basename(inputPath, extension)}-signed-${hash}${extension}`)\n }\n\n async getCertificateFromStoreInfo(options: WindowsConfiguration, vm: VmManager): Promise<CertificateFromStoreInfo> {\n const signing = getSigntoolFamilyConfig(options) as WindowsSigntoolSigningConfig | WindowsHsmSigningConfig | null\n const certificateSubjectName = signing?.certificateSubjectName\n const certificateSha1 = signing?.certificateSha1?.toUpperCase()\n\n const ps = await vm.powershellCommand.value\n // the non-ASCII characters of a subject are escaped, so they read back losslessly whatever the console code page\n const rawResult = await vm.exec(ps, [\n \"-NoProfile\",\n \"-NonInteractive\",\n \"-Command\",\n `${POWERSHELL_ASCII_ESCAPE_FUNCTION}; $json = Get-ChildItem -Recurse Cert: -CodeSigningCert | Select-Object -Property Subject,PSParentPath,Thumbprint | ConvertTo-Json -Compress; if ($json) { ConvertTo-AsciiEscaped $json }`,\n ])\n const certList = rawResult.length === 0 ? [] : asArray<CertInfo>(JSON.parse(rawResult))\n for (const certInfo of certList) {\n if (\n (certificateSubjectName != null && !certInfo.Subject.includes(certificateSubjectName)) ||\n (certificateSha1 != null && certInfo.Thumbprint.toUpperCase() !== certificateSha1)\n ) {\n continue\n }\n\n const parentPath = certInfo.PSParentPath\n const store = parentPath.substring(parentPath.lastIndexOf(\"\\\\\") + 1)\n log.debug({ store, PSParentPath: parentPath }, \"auto-detect certificate store\")\n // https://github.com/electron-userland/electron-builder/issues/1717\n const isLocalMachineStore = parentPath.includes(\"Certificate::LocalMachine\")\n log.debug(null, \"auto-detect using of LocalMachine store\")\n return {\n thumbprint: certInfo.Thumbprint,\n subject: certInfo.Subject,\n store,\n isLocalMachineStore,\n }\n }\n\n throw new Error(`Cannot find certificate ${certificateSubjectName || certificateSha1}, all certs: ${rawResult}`)\n }\n\n async getToolPath(isWin = process.platform === \"win32\"): Promise<ToolInfo> {\n return getSignToolPath(this.packager.config.toolsets?.winCodeSign, isWin, this.packager.buildResourcesDir)\n }\n\n async doSign(configuration: CustomWindowsSignTaskConfiguration, packager: WinPackager) {\n // https://github.com/electron-userland/electron-builder/pull/1944\n const timeout = parseInt(process.env.SIGNTOOL_TIMEOUT as any, 10) || 10 * 60 * 1000\n let args: Array<string>\n let vm: VmManager\n // cscInfo can be null (e.g. PKCS#11 with no cert file); guard before using `in`.\n // CertificateFromStoreInfo (no `file` property) requires a Windows VM for cert-store lookup.\n const cscInfo = configuration.cscInfo\n const useVmIfNotOnWin = configuration.path.endsWith(\".appx\") || (cscInfo != null && !(\"file\" in cscInfo))\n const isWin = process.platform === \"win32\" || useVmIfNotOnWin\n const toolInfo = await getSignToolPath(this.packager.config.toolsets?.winCodeSign, isWin, this.packager.buildResourcesDir)\n const tool = toolInfo.path\n if (useVmIfNotOnWin) {\n vm = await packager.vm.value\n args = this.computeSignToolArgs(configuration, isWin, vm)\n } else {\n vm = new VmManager()\n args = configuration.computeSignToolArgs(isWin)\n }\n\n // signtool.exe (`/f`) is not safe to run concurrently — it races on the shared per-user crypto store.\n // Serialize real-Windows signtool invocations across processes; osslsigncode (`!isWin`) is file-isolated.\n const execSign = () => vm.exec(tool, args, { timeout, env: { ...process.env, ...(toolInfo.env || {}) } })\n await retry(() => (isWin ? withSigntoolLock(execSign) : execSign()), {\n retries: 2,\n interval: 15000,\n backoff: 10000,\n shouldRetry: (e: any) => {\n if (\n e.message.includes(\"The file is being used by another process\") ||\n e.message.includes(\"The specified timestamp server either could not be reached\") ||\n e.message.includes(\"No certificates were found that met all the given criteria.\") ||\n // Transient failure of SignerSignEx after cert selection, typically a concurrent-signtool race\n // on the per-user crypto store; the cross-process lock above makes this rare, retry covers the rest.\n e.message.includes(\"An error occurred while attempting to load the signing certificate\")\n ) {\n log.warn(`Attempt to code sign failed, another attempt will be made in 15 seconds: ${e.message}`)\n return true\n }\n return false\n },\n })\n }\n}\n\nexport class SigntoolSignManager extends SigntoolBaseSignManager {\n protected computeWindowsSignArgs(options: WindowsSignTaskConfiguration, vm: VmManager): Array<string> {\n const signing = getSigntoolFamilyConfig(options.options)\n\n const inputFile = vm.toVmFile(options.path)\n const args = [\"sign\"]\n\n // Timestamping\n if (process.env.ELECTRON_BUILDER_OFFLINE !== \"true\") {\n const isRfc3161 = options.isNest || options.hash === \"sha256\"\n args.push(isRfc3161 ? \"/tr\" : \"/t\")\n const timestampUrl = isRfc3161 ? signing?.rfc3161TimeStampServer || \"http://timestamp.digicert.com\" : signing?.timeStampServer || \"http://timestamp.digicert.com\"\n args.push(timestampUrl)\n }\n\n // Certificate\n this.addCertificateArgs(args, options, vm, true)\n\n // Hash algorithm\n if (this.isLegacyToolset()) {\n // Legacy v0.0.0: Only add /fd for non-SHA1 (original behavior)\n if (options.hash !== \"sha1\") {\n args.push(\"/fd\", options.hash)\n if (process.env.ELECTRON_BUILDER_OFFLINE !== \"true\") {\n args.push(\"/td\", \"sha256\")\n }\n }\n } else {\n // Modern: Always add /fd (required by new Windows Kits)\n args.push(\"/fd\", options.hash.toLowerCase())\n // Only add /td for RFC3161 timestamps (incompatible with /t)\n if (process.env.ELECTRON_BUILDER_OFFLINE !== \"true\" && (options.isNest || options.hash === \"sha256\")) {\n args.push(\"/td\", \"sha256\")\n }\n }\n\n // Optional parameters\n this.addCommonSigningArgs(args, options, vm, true)\n\n // Windows-specific\n args.push(\"/debug\")\n args.push(inputFile) // Must be last\n\n return args\n }\n\n protected computeOsslsigncodeArgs(options: WindowsSignTaskConfiguration, vm: VmManager): Array<string> {\n const signing = getSigntoolFamilyConfig(options.options)\n\n const inputFile = vm.toVmFile(options.path)\n const outputPath = this.getOutputPath(inputFile, options.hash)\n options.resultOutputPath = outputPath\n\n const args = [\"sign\", \"-in\", inputFile, \"-out\", outputPath]\n\n // Timestamping\n if (process.env.ELECTRON_BUILDER_OFFLINE !== \"true\") {\n const timestampUrl = signing?.timeStampServer || \"http://timestamp.digicert.com\"\n args.push(\"-t\", timestampUrl)\n }\n\n // Certificate file\n this.addCertificateArgs(args, options, vm, false)\n\n // Hash algorithm\n args.push(\"-h\", options.hash.toLowerCase())\n\n // Optional parameters (name, site, nest, password, additionalCert)\n this.addCommonSigningArgs(args, options, vm, false)\n\n // Proxy support\n const httpsProxy = process.env.HTTPS_PROXY\n if (httpsProxy?.length) {\n args.push(\"-p\", httpsProxy)\n }\n\n return args\n }\n}\n\n/**\n * The hash algorithms to sign `filePath` with, one signing pass each.\n *\n * - `.msi` holds a single signature, so it is signed once: with `sha256` unless `sha1` is the only algorithm requested.\n * - `.appx`, `.msix` and `.msixbundle` are always `sha256`.\n * - Everything else uses the configured list, defaulting to dual signing with `sha1` then `sha256`.\n *\n * Extensions are matched case-insensitively (`app.MSI` is an MSI). An empty list is a configuration error: it would\n * run no signing pass while the file is still reported as signed.\n */\nexport function resolveSigningHashAlgorithms(filePath: string, configured: Array<\"sha1\" | \"sha256\"> | \"sha1\" | \"sha256\" | null | undefined): Array<\"sha1\" | \"sha256\"> {\n const requested = configured == null ? null : asArray(configured)\n if (requested != null && requested.length === 0) {\n throw new InvalidConfigurationError(\n `win.sign.signingHashAlgorithms is an empty list, so no signing pass would run. List at least one of \"sha1\" or \"sha256\", remove the option to use the default [\"sha1\", \"sha256\"], or set win.sign to false to disable Windows signing.`\n )\n }\n const ext = path.extname(filePath).toLowerCase()\n if (ext === \".msi\") {\n return [requested != null && !requested.includes(\"sha256\") ? \"sha1\" : \"sha256\"]\n }\n if (ext === \".appx\" || ext === \".msix\" || ext === \".msixbundle\") {\n return [\"sha256\"]\n }\n return requested ?? [\"sha1\", \"sha256\"]\n}\n"]}
|
|
1
|
+
{"version":3,"file":"signtoolBaseSignManager.js","sourceRoot":"","sources":["../../../src/codeSign/win/signtoolBaseSignManager.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,OAAO,EAAE,yBAAyB,EAAE,GAAG,EAAE,KAAK,EAAE,MAAM,cAAc,CAAA;AAC7E,OAAO,EAAE,kBAAkB,EAAE,QAAQ,EAAE,OAAO,EAAE,gCAAgC,EAAE,MAAM,sBAAsB,CAAA;AAC9G,OAAO,QAAQ,MAAM,UAAU,CAAA;AAC/B,OAAO,EAAE,IAAI,EAAE,MAAM,UAAU,CAAA;AAC/B,OAAO,KAAK,IAAI,MAAM,MAAM,CAAA;AAE5B,OAAO,EACL,wBAAwB,EACxB,kCAAkC,GAKnC,MAAM,6BAA6B,CAAA;AACpC,OAAO,UAAU,MAAM,iCAAiC,CAAA;AACxD,OAAO,UAAU,MAAM,iCAAiC,CAAA;AACxD,OAAO,EAAE,eAAe,EAAE,MAAM,+BAA+B,CAAA;AAC/D,OAAO,EAAE,4BAA4B,EAAY,MAAM,2BAA2B,CAAA;AAClF,OA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,CAAC,CAAA;QAC7B,CAAC;QAED,OAAO,IAAI,CAAA;IACb,CAAC;CACF;AAED;;;;;;;;;GASG;AACH,MAAM,UAAU,4BAA4B,CAAC,QAAgB,EAAE,UAA2E;IACxI,MAAM,SAAS,GAAG,UAAU,IAAI,IAAI,CAAC,CAAC,CAAC,IAAI,CAAC,CAAC,CAAC,OAAO,CAAC,UAAU,CAAC,CAAA;IACjE,IAAI,SAAS,IAAI,IAAI,IAAI,SAAS,CAAC,MAAM,KAAK,CAAC,EAAE,CAAC;QAChD,MAAM,IAAI,yBAAyB,CACjC,uOAAuO,CACxO,CAAA;IACH,CAAC;IACD,MAAM,GAAG,GAAG,IAAI,CAAC,OAAO,CAAC,QAAQ,CAAC,CAAC,WAAW,EAAE,CAAA;IAChD,IAAI,GAAG,KAAK,MAAM,EAAE,CAAC;QACnB,OAAO,CAAC,SAAS,IAAI,IAAI,IAAI,CAAC,SAAS,CAAC,QAAQ,CAAC,QAAQ,CAAC,CAAC,CAAC,CAAC,MAAM,CAAC,CAAC,CAAC,QAAQ,CAAC,CAAA;IACjF,CAAC;IACD,IAAI,GAAG,KAAK,OAAO,IAAI,GAAG,KAAK,OAAO,IAAI,GAAG,KAAK,aAAa,EAAE,CAAC;QAChE,OAAO,CAAC,QAAQ,CAAC,CAAA;IACnB,CAAC;IACD,OAAO,SAAS,IAAI,CAAC,MAAM,EAAE,QAAQ,CAAC,CAAA;AACxC,CAAC","sourcesContent":["import { asArray, InvalidConfigurationError, log, retry } from \"builder-util\"\nimport { matchPublisherName, MemoLazy, parseDn, POWERSHELL_ASCII_ESCAPE_FUNCTION } from \"builder-util-runtime\"\nimport _fsExtra from \"fs-extra\"\nimport { Lazy } from \"lazy-val\"\nimport * as path from \"path\"\nimport { Target } from \"../../core.js\"\nimport {\n isWindowsSigningDisabled,\n resolveWindowsSigningConfiguration,\n WindowsConfiguration,\n WindowsHsmSigningConfig,\n WindowsSigntoolFamilyConfig,\n WindowsSigntoolSigningConfig,\n} from \"../../options/winOptions.js\"\nimport AppXTarget from \"../../targets/win/AppxTarget.js\"\nimport MsixTarget from \"../../targets/win/MsixTarget.js\"\nimport { getSignToolPath } from \"../../toolsets/winCodeSign.js\"\nimport { envWithoutPublishCredentials, ToolInfo } from \"../../util/bundledTool.js\"\nimport { isOfflineModeEnabled } from \"../../util/flags.js\"\nimport { resolveFunction } from \"../../util/resolve.js\"\nimport { withSigntoolLock } from \"../../util/toolsetLock.js\"\nimport { readCertInfo, readCertInfoFromX509 } from \"../certInfo.js\"\nimport { VmManager } from \"../../vm/vm.js\"\nimport type { WinPackager } from \"../../winPackager.js\"\nimport { importCertificate } from \"../codesign.js\"\nimport { derivePublisherName, PUBLISHER_NAME_DN_DOCS_URL, validatePublisherNameFormat } from \"./publisherName.js\"\nimport type { SignManager } from \"./signManager.js\"\nimport { WindowsSignOptions } from \"./windowsCodeSign.js\"\nimport { SignFileResult } from \"../signResult.js\"\nimport { BUILD_CHANGES_URL } from \"../../util/config/legacyOptions.js\"\n\nconst PUBLISHER_NAME_DOCS = `${BUILD_CHANGES_URL}#windows-publishername-is-validated-against-the-signing-certificate`\n\nconst { rename } = _fsExtra\n\nexport type CustomWindowsSign = (configuration: CustomWindowsSignTaskConfiguration, packager?: WinPackager) => Promise<any>\n\nexport interface WindowsSignToolOptions extends WindowsSignOptions {\n readonly name: string\n readonly site: string | null\n}\n\nexport interface FileCodeSigningInfo {\n readonly file: string\n readonly password: string | null\n}\n\nexport interface WindowsSignTaskConfiguration extends WindowsSignToolOptions {\n readonly cscInfo: FileCodeSigningInfo | CertificateFromStoreInfo | null\n\n // set if output path differs from input (e.g. osslsigncode cannot sign file in-place)\n resultOutputPath?: string\n\n hash: string\n isNest: boolean\n}\n\nexport interface CustomWindowsSignTaskConfiguration extends WindowsSignTaskConfiguration {\n computeSignToolArgs(isWin: boolean): Array<string>\n}\n\nexport interface CertificateInfo {\n readonly commonName: string\n readonly bloodyMicrosoftSubjectDn: string\n /**\n * The subject in the format Windows reports it (`X509Certificate2.Subject`), which electron-updater matches\n * publisherName against. Unset when `bloodyMicrosoftSubjectDn` already is in that format (certificate store).\n */\n readonly windowsSubjectDn?: string\n}\n\nexport interface CertificateFromStoreInfo {\n thumbprint: string\n subject: string\n store: string\n isLocalMachineStore: boolean\n}\n\ninterface CertInfo {\n Subject: string\n Thumbprint: string\n PSParentPath: string\n}\n\n/** Extracts the non-Azure signing config from WindowsConfiguration, or null for Azure/unset/disabled. */\nexport function getSigntoolFamilyConfig(config: WindowsConfiguration): WindowsSigntoolFamilyConfig | null {\n const s = resolveWindowsSigningConfiguration(config)\n if (s == null || s.type === \"azure\") {\n return null\n }\n return s\n}\n\n/** The certificate subject in the format Windows reports it, which electron-updater matches publisherName against. */\nexport function certificateWindowsSubjectDn(certInfo: CertificateInfo): string {\n return certInfo.windowsSubjectDn ?? certInfo.bloodyMicrosoftSubjectDn\n}\n\n/**\n * Matches configured publisher names against a certificate subject with the matcher electron-updater's update\n * signature verifier uses ({@link matchPublisherName}): a name must be a Distinguished Name (DN), and every RDN it\n * specifies must equal the certificate subject's (extra subject RDNs are ignored). Passes when ANY\n * configured name matches — multiple names are supported for certificate rotation. The subject is taken in the format\n * Windows reports it (as the updater sees it).\n */\nexport function publisherNameMatchesCertificate(publisherNames: Array<string>, certInfo: CertificateInfo): boolean {\n // matchPublisherName takes the parsed Get-AuthenticodeSignature output, as electron-updater passes it\n return matchPublisherName({ SignerCertificate: { Subject: certificateWindowsSubjectDn(certInfo) } }, publisherNames)\n}\n\nexport abstract class SigntoolBaseSignManager implements SignManager {\n protected readonly platformSpecificBuildOptions: WindowsConfiguration\n\n constructor(protected readonly packager: WinPackager) {\n this.platformSpecificBuildOptions = packager.platformOptions\n }\n\n readonly computedPublisherName = new Lazy<Array<string> | null>(async () => {\n // `win.sign: false` / `null` signs nothing, so no publisherName is derived: a build that writes app-update.yml then needs\n // win.verifyUpdateCodeSignature: false (or a win.sign object with publisherName), see missingUpdatePublisherNameError.\n if (isWindowsSigningDisabled(this.platformSpecificBuildOptions)) {\n return null\n }\n\n const signing = getSigntoolFamilyConfig(this.platformSpecificBuildOptions)\n const publisherName = signing?.publisherName\n if (publisherName === null) {\n return null\n } else if (publisherName != null) {\n await this.explicitPublisherNameValidation.value\n return asArray(publisherName)\n }\n\n // A custom `sign` hook signs with a certificate electron-builder doesn't see (not even one named in the config is known to be the one\n // the hook uses), so the publisher name that electron-updater trusts must be configured explicitly.\n if (signing?.sign != null) {\n throw new InvalidConfigurationError(\n \"A custom Windows signing hook (`win.sign.sign`) is configured without `win.sign.publisherName`. \" +\n \"electron-builder cannot tell which certificate the hook signs with, and electron-updater verifies the signature of downloaded updates against the publisherName in app-update.yml. \" +\n 'Set `win.sign.publisherName` to the subject of the certificate that your hook signs with, as a distinguished name (e.g. \"CN=My Company, O=My Company, C=US\"), ' +\n \"or set `win.verifyUpdateCodeSignature: false` (only if your updates are not Authenticode-signed or you don't use electron-updater) to opt out of update signature verification explicitly. \" +\n `See ${PUBLISHER_NAME_DOCS}`\n )\n }\n\n const certInfo = await this.lazyCertInfo.value\n if (certInfo?.commonName) {\n // `CN=<common name>`, quoted as Windows reports the signer subject (which electron-updater 7 matches against): pinning only the CN\n // keeps updates working across a certificate renewal that changes other subject attributes. A stricter pin is an explicit publisherName.\n return [derivePublisherName(certInfo.commonName)]\n }\n // Signed with a certificate without a CN (or whose subject cannot be read): electron-updater verifies downloaded updates against the\n // publisherName in app-update.yml, so the build needs one.\n if ((await this.cscInfo.value) != null) {\n throw new InvalidConfigurationError(\n \"Windows code signing is configured, but the publisher name cannot be determined at build time (the signing certificate has no Common Name). \" +\n \"electron-updater verifies the signature of downloaded updates against the publisherName in app-update.yml. \" +\n 'Set `win.sign.publisherName` to the subject of the certificate that signs your app, as a distinguished name (e.g. \"CN=My Company, O=My Company, C=US\"), ' +\n \"or set `win.verifyUpdateCodeSignature: false` (only if your updates are not Authenticode-signed or you don't use electron-updater) to opt out of update signature verification explicitly. \" +\n `See ${PUBLISHER_NAME_DN_DOCS_URL}`\n )\n }\n return null\n })\n\n readonly lazyCertInfo = new MemoLazy<MemoLazy<WindowsConfiguration, FileCodeSigningInfo | CertificateFromStoreInfo | null>, CertificateInfo | null>(\n () => this.cscInfo,\n async csc => {\n const cscInfo = await csc.value\n if (cscInfo == null) {\n return null\n }\n\n if (\"subject\" in cscInfo) {\n const bloodyMicrosoftSubjectDn = cscInfo.subject\n return {\n // empty for a subject without a CN, like readCertInfo, so computedPublisherName requires an explicit publisherName\n commonName: parseDn(bloodyMicrosoftSubjectDn).get(\"CN\") ?? \"\",\n // read from the Windows certificate store, so already in the format Windows reports (windowsSubjectDn falls back to it)\n bloodyMicrosoftSubjectDn,\n }\n }\n\n const cscFile = cscInfo.file\n if (cscFile == null) {\n return null\n }\n\n const certExt = path.extname(cscFile).toLowerCase()\n if (certExt === \".p12\" || certExt === \".pfx\") {\n return await this.getCertInfo(cscFile, cscInfo.password || \"\")\n }\n // Non-PKCS12 files (.crt, .cer): parse as plain X.509.\n // Returns null when the CN is absent — caller must set publisherName explicitly.\n return await readCertInfoFromX509(cscFile)\n }\n )\n\n // Memoized so the check runs once per build even though signFile is invoked once per file.\n private readonly explicitPublisherNameValidation = new Lazy<void>(() => this.validateExplicitPublisherName())\n\n /**\n * When `publisherName` is explicitly configured, fail the build if an entry is not a distinguished name\n * (electron-updater 7 never matches one), whatever the signing route. Then, when the subject of the local code\n * signing certificate is known, fail the build if none of the configured names match the certificate.\n * This catches signing with the wrong certificate at build time — otherwise the mismatch only\n * surfaces at update time, when electron-updater rejects every update signed with that\n * certificate.\n *\n * The check is intentionally skipped whenever the actual signing certificate's subject is not\n * genuinely known: custom `sign` hooks, PKCS#11 without an extractable certificate file,\n * x509 certificate files without a CN, or any error while reading certificate info.\n * An explicit `publisherName: null` has nothing to validate (a build that writes `app-update.yml` with it fails in PublishManager).\n */\n protected async validateExplicitPublisherName(): Promise<void> {\n const signing = getSigntoolFamilyConfig(this.platformSpecificBuildOptions)\n const publisherName = signing?.publisherName\n if (publisherName == null) {\n // not configured (auto-derive) or explicit `null` (no opt-out any more: rejected where app-update.yml is written) — nothing to validate\n return\n }\n validatePublisherNameFormat(publisherName)\n if (signing?.sign != null) {\n // custom sign hook: electron-builder does not know which certificate the hook actually signs with\n return\n }\n const publisherNames = asArray(publisherName)\n if (publisherNames.length === 0) {\n return\n }\n\n let certInfo: CertificateInfo | null\n try {\n certInfo = await this.lazyCertInfo.value\n } catch (e: any) {\n // this check must only fire when the signing certificate's subject is genuinely known\n log.debug({ error: e.message || e }, \"skipping publisherName validation against the signing certificate (cannot read certificate info)\")\n return\n }\n if (certInfo == null) {\n return\n }\n\n if (!publisherNameMatchesCertificate(publisherNames, certInfo)) {\n throw new InvalidConfigurationError(\n `The configured publisherName does not match the subject of the code signing certificate. ` +\n `This usually means the build is signing with the wrong certificate (for example, a code signing certificate for another platform or team leaked into WIN_CSC_LINK/CSC_LINK in CI) — electron-updater would reject every update signed with it.\\n` +\n ` Configured publisherName: ${publisherNames.join(\" | \")}\\n` +\n ` Certificate subject: ${certificateWindowsSubjectDn(certInfo)}\\n` +\n `Fix win.sign.publisherName (or sign with the intended certificate). To opt out of update signature verification entirely, set win.verifyUpdateCodeSignature: false.`\n )\n }\n }\n\n readonly cscInfo = new MemoLazy<WindowsConfiguration, FileCodeSigningInfo | CertificateFromStoreInfo | null>(\n () => this.platformSpecificBuildOptions,\n platformSpecificBuildOptions => {\n // `win.sign: false` / `null` signs nothing: no certificate is read (not even from CSC_LINK / WIN_CSC_LINK), so none\n // supplies an AppX/MSIX publisher, a publisherName for app-update.yml or a build-cache digest.\n if (isWindowsSigningDisabled(platformSpecificBuildOptions)) {\n return Promise.resolve(null)\n }\n const signing = getSigntoolFamilyConfig(platformSpecificBuildOptions)\n // signtool is the implicit default when win.sign is unset, so an absent config still\n // honours the WIN_CSC_LINK/cscLink fallback below (hsm/pkcs11 set signing.type explicitly).\n const isSigntool = signing == null || signing.type === \"signtool\"\n\n // signtool + hsm: store-based cert takes priority\n const subjectName = (signing as WindowsSigntoolSigningConfig | WindowsHsmSigningConfig | null)?.certificateSubjectName\n const shaType = (signing as WindowsSigntoolSigningConfig | WindowsHsmSigningConfig | null)?.certificateSha1\n if (subjectName != null || shaType != null) {\n return this.packager.vm.value\n .then(vm => this.getCertificateFromStoreInfo(platformSpecificBuildOptions, vm))\n .catch((e: any) => {\n // https://github.com/electron-userland/electron-builder/pull/2397\n if (signing?.sign == null) {\n throw e\n } else {\n log.debug({ error: e }, \"getCertificateFromStoreInfo error\")\n return null\n }\n })\n }\n\n const certificateFile = signing?.certificateFile\n if (certificateFile != null) {\n // Only signtool mode uses a password (HSM private key lives in the HSM, not the cert file)\n const certificatePassword = isSigntool ? this.packager.getCscPassword() : null\n return Promise.resolve({\n file: certificateFile,\n password: certificatePassword == null ? null : certificatePassword.trim(),\n })\n }\n\n // WIN_CSC_LINK env var fallback: only for signtool mode (including the implicit default)\n if (isSigntool) {\n const cscLink = this.packager.getCscLink(\"WIN_CSC_LINK\")\n if (cscLink == null || cscLink === \"\") {\n return Promise.resolve(null)\n }\n\n return importCertificate(cscLink, this.packager.tempDirManager, this.packager.projectDir)\n .catch((e: any) => {\n if (e instanceof InvalidConfigurationError) {\n throw new InvalidConfigurationError(`Env WIN_CSC_LINK is not correct, cannot resolve: ${e.message}`)\n } else {\n throw e\n }\n })\n .then(p => ({\n file: p,\n password: this.packager.getCscPassword(),\n }))\n }\n\n return Promise.resolve(null)\n }\n )\n\n initialize(): Promise<void> {\n return Promise.resolve()\n }\n\n // https://github.com/electron-userland/electron-builder/issues/2108#issuecomment-333200711\n async computePublisherName(target: Target, publisherName: string | null) {\n if ((target instanceof AppXTarget || target instanceof MsixTarget) && (await this.cscInfo.value) == null) {\n log.info({ reason: \"Windows Store only build\" }, \"AppX/MSIX package is not signed\")\n return publisherName ?? \"CN=ms\"\n }\n\n // When a signing cert is available, the cert's subject MUST be used so the APPX package\n // Publisher attribute matches the certificate — any mismatch causes SignerSign to fail with\n // ERROR_BAD_FORMAT. Only honour a user-supplied publisherName if it was explicitly configured\n // (non-null); otherwise derive from the certificate. The subject is written in the format Windows reports it\n // (`, `-separated, Windows attribute names such as S): MakeAppx rejects a multi-RDN Publisher separated by a bare `,`\n // or using the OpenSSL name ST.\n const certInfo = await this.lazyCertInfo.value\n const publisher = publisherName ?? (certInfo == null ? null : certificateWindowsSubjectDn(certInfo))\n if (publisher == null) {\n throw new Error(\"Internal error: cannot compute subject using certificate info\")\n }\n return publisher\n }\n\n /**\n * Called when cscInfo is null. Returns true to skip signing, false to proceed, or throws.\n * Override in subclasses with different null-cert behaviour (HSM throws, PKCS#11 proceeds).\n */\n protected handleNullCscInfo(customSign: CustomWindowsSign | string | null | undefined): boolean {\n return !customSign // default: skip when no cert and no custom sign hook\n }\n\n async signFile(options: WindowsSignOptions): Promise<SignFileResult> {\n const signing = getSigntoolFamilyConfig(options.options)\n const hashes = resolveSigningHashAlgorithms(options.path, signing?.signingHashAlgorithms)\n\n const name = this.packager.appInfo.productName\n const site = await this.packager.appInfo.computePackageUrl()\n\n const customSign = await resolveFunction(this.packager.appInfo.type, signing?.sign, \"sign\", await this.packager.getWorkspaceRoot())\n\n const cscInfo = await this.cscInfo.value\n\n if (cscInfo) {\n let logInfo: any = {\n file: log.filePath(options.path),\n }\n if (\"file\" in cscInfo) {\n logInfo = { ...logInfo, certificateFile: cscInfo.file }\n } else {\n logInfo = {\n ...logInfo,\n subject: cscInfo.subject,\n thumbprint: cscInfo.thumbprint,\n store: cscInfo.store,\n user: cscInfo.isLocalMachineStore ? \"local machine\" : \"current user\",\n }\n }\n log.info(logInfo, \"signing\")\n } else if (this.handleNullCscInfo(customSign)) {\n // the canonical \"signing skipped\" message is logged once in signWindows, which receives this reason\n return \"skipped:no-certificate\"\n }\n // validate an explicitly configured publisherName (its format on every signing route, and against the signing certificate when\n // known) before the first file is signed, so a wrong-certificate build fails even when no publish config exists\n await this.explicitPublisherNameValidation.value\n\n const executor = customSign || ((config: CustomWindowsSignTaskConfiguration, packager: WinPackager) => this.doSign(config, packager))\n let isNest = false\n for (const hash of hashes) {\n const taskConfiguration: WindowsSignTaskConfiguration = { ...options, name, site, cscInfo, hash, isNest }\n await Promise.resolve(\n executor(\n {\n ...taskConfiguration,\n computeSignToolArgs: isWin => this.computeSignToolArgs(taskConfiguration, isWin),\n },\n this.packager\n )\n )\n isNest = true\n if (taskConfiguration.resultOutputPath != null) {\n await rename(taskConfiguration.resultOutputPath, options.path)\n }\n }\n\n return customSign ? \"signed:custom\" : \"signed\"\n }\n\n async getCertInfo(file: string, password: string): Promise<CertificateInfo> {\n const errorMessagePrefix = \"Cannot extract publisher name from code signing certificate. As workaround, set win.sign.publisherName. Error: \"\n try {\n return await readCertInfo(file, password)\n } catch (e: any) {\n throw new InvalidConfigurationError(`${errorMessagePrefix}${e.message || e}`)\n }\n }\n\n // on windows be aware of http://stackoverflow.com/a/32640183/1910191\n computeSignToolArgs(options: WindowsSignTaskConfiguration, isWin: boolean, vm: VmManager = new VmManager()): Array<string> {\n if (isOfflineModeEnabled()) {\n log\n .once(\"offline-skips-timestamp\", options.cscInfo)\n .warn(\n null,\n \"ELECTRON_BUILDER_OFFLINE is set, so Windows signatures get no timestamp and stop validating once the signing certificate expires. \" +\n \"ELECTRON_BUILDER_OFFLINE=1 skips the timestamp server the same as ELECTRON_BUILDER_OFFLINE=true. \" +\n \"Unset ELECTRON_BUILDER_OFFLINE for release builds. \" +\n `See ${BUILD_CHANGES_URL}#electron_builder_offline-skips-the-signing-timestamp`\n )\n }\n return isWin ? this.computeWindowsSignArgs(options, vm) : this.computeOsslsigncodeArgs(options, vm)\n }\n\n protected isLegacyToolset(): boolean {\n const v = this.packager.config.toolsets?.winCodeSign\n // Only an explicit \"0.0.0\" pin is legacy; unset / null / \"latest\" / custom now resolve to a modern bundle.\n return v === \"0.0.0\"\n }\n\n protected abstract computeWindowsSignArgs(options: WindowsSignTaskConfiguration, vm: VmManager): Array<string>\n protected abstract computeOsslsigncodeArgs(options: WindowsSignTaskConfiguration, vm: VmManager): Array<string>\n\n // allowX509: set to true by HsmSignManager to permit .crt/.cer (public chain only, key is in HSM).\n protected addCertificateArgs(args: Array<string>, options: WindowsSignTaskConfiguration, vm: VmManager, isWin: boolean, allowX509 = false): void {\n if (options.cscInfo == null) {\n throw new Error(\"No code signing certificate configured. Provide certificateFile, certificateSha1, or certificateSubjectName.\")\n }\n const certificateFile = (options.cscInfo as FileCodeSigningInfo).file\n\n if (certificateFile == null) {\n // Certificate from store (Windows only)\n if (!isWin) {\n throw new Error(\"certificateSha1/certificateSubjectName supported only on Windows\")\n }\n\n const cscInfo = options.cscInfo as CertificateFromStoreInfo\n args.push(\"/sha1\", cscInfo.thumbprint)\n args.push(\"/s\", cscInfo.store)\n if (cscInfo.isLocalMachineStore) {\n args.push(\"/sm\")\n }\n } else {\n const certExtension = path.extname(certificateFile).toLowerCase()\n\n if (certExtension === \".p12\" || certExtension === \".pfx\") {\n args.push(isWin ? \"/f\" : \"-pkcs12\", vm.toVmFile(certificateFile))\n } else if (isWin && allowX509 && (certExtension === \".crt\" || certExtension === \".cer\")) {\n args.push(\"/f\", vm.toVmFile(certificateFile))\n } else {\n throw new InvalidConfigurationError(`Please specify pkcs12 (.p12/.pfx) file, ${certificateFile} is not correct`)\n }\n }\n }\n\n protected addCommonSigningArgs(args: Array<string>, options: WindowsSignTaskConfiguration, vm: VmManager, isWin: boolean): void {\n if (options.name) {\n args.push(isWin ? \"/d\" : \"-n\", options.name)\n }\n\n if (options.site) {\n args.push(isWin ? \"/du\" : \"-i\", options.site)\n }\n\n if (options.isNest) {\n args.push(isWin ? \"/as\" : \"-nest\")\n }\n\n const password = (options.cscInfo as FileCodeSigningInfo)?.password\n if (password) {\n args.push(isWin ? \"/p\" : \"-pass\", password)\n }\n\n const signing = getSigntoolFamilyConfig(options.options)\n const additionalCert = signing?.additionalCertificateFile\n if (additionalCert) {\n args.push(isWin ? \"/ac\" : \"-ac\", vm.toVmFile(additionalCert))\n }\n }\n\n getOutputPath(inputPath: string, hash: string) {\n const extension = path.extname(inputPath)\n return path.join(path.dirname(inputPath), `${path.basename(inputPath, extension)}-signed-${hash}${extension}`)\n }\n\n async getCertificateFromStoreInfo(options: WindowsConfiguration, vm: VmManager): Promise<CertificateFromStoreInfo> {\n const signing = getSigntoolFamilyConfig(options) as WindowsSigntoolSigningConfig | WindowsHsmSigningConfig | null\n const certificateSubjectName = signing?.certificateSubjectName\n const certificateSha1 = signing?.certificateSha1?.toUpperCase()\n\n const ps = await vm.powershellCommand.value\n // the non-ASCII characters of a subject are escaped, so they read back losslessly whatever the console code page\n const rawResult = await vm.exec(ps, [\n \"-NoProfile\",\n \"-NonInteractive\",\n \"-Command\",\n `${POWERSHELL_ASCII_ESCAPE_FUNCTION}; $json = Get-ChildItem -Recurse Cert: -CodeSigningCert | Select-Object -Property Subject,PSParentPath,Thumbprint | ConvertTo-Json -Compress; if ($json) { ConvertTo-AsciiEscaped $json }`,\n ])\n const certList = rawResult.length === 0 ? [] : asArray<CertInfo>(JSON.parse(rawResult))\n for (const certInfo of certList) {\n if (\n (certificateSubjectName != null && !certInfo.Subject.includes(certificateSubjectName)) ||\n (certificateSha1 != null && certInfo.Thumbprint.toUpperCase() !== certificateSha1)\n ) {\n continue\n }\n\n const parentPath = certInfo.PSParentPath\n const store = parentPath.substring(parentPath.lastIndexOf(\"\\\\\") + 1)\n log.debug({ store, PSParentPath: parentPath }, \"auto-detect certificate store\")\n // https://github.com/electron-userland/electron-builder/issues/1717\n const isLocalMachineStore = parentPath.includes(\"Certificate::LocalMachine\")\n log.debug(null, \"auto-detect using of LocalMachine store\")\n return {\n thumbprint: certInfo.Thumbprint,\n subject: certInfo.Subject,\n store,\n isLocalMachineStore,\n }\n }\n\n throw new Error(`Cannot find certificate ${certificateSubjectName || certificateSha1}, all certs: ${rawResult}`)\n }\n\n async getToolPath(isWin = process.platform === \"win32\"): Promise<ToolInfo> {\n return getSignToolPath(this.packager.config.toolsets?.winCodeSign, isWin, this.packager.buildResourcesDir)\n }\n\n async doSign(configuration: CustomWindowsSignTaskConfiguration, packager: WinPackager) {\n // https://github.com/electron-userland/electron-builder/pull/1944\n const timeout = parseInt(process.env.SIGNTOOL_TIMEOUT as any, 10) || 10 * 60 * 1000\n let args: Array<string>\n let vm: VmManager\n // cscInfo can be null (e.g. PKCS#11 with no cert file); guard before using `in`.\n // CertificateFromStoreInfo (no `file` property) requires a Windows VM for cert-store lookup.\n const cscInfo = configuration.cscInfo\n const useVmIfNotOnWin = configuration.path.endsWith(\".appx\") || (cscInfo != null && !(\"file\" in cscInfo))\n const isWin = process.platform === \"win32\" || useVmIfNotOnWin\n const toolInfo = await getSignToolPath(this.packager.config.toolsets?.winCodeSign, isWin, this.packager.buildResourcesDir)\n const tool = toolInfo.path\n if (useVmIfNotOnWin) {\n vm = await packager.vm.value\n args = this.computeSignToolArgs(configuration, isWin, vm)\n } else {\n vm = new VmManager()\n args = configuration.computeSignToolArgs(isWin)\n }\n\n // signtool.exe (`/f`) is not safe to run concurrently — it races on the shared per-user crypto store.\n // Serialize real-Windows signtool invocations across processes; osslsigncode (`!isWin`) is file-isolated.\n const execSign = () => vm.exec(tool, args, { timeout, env: envWithoutPublishCredentials(toolInfo.env) })\n await retry(() => (isWin ? withSigntoolLock(execSign) : execSign()), {\n retries: 2,\n interval: 15000,\n backoff: 10000,\n shouldRetry: (e: any) => {\n if (\n e.message.includes(\"The file is being used by another process\") ||\n e.message.includes(\"The specified timestamp server either could not be reached\") ||\n e.message.includes(\"No certificates were found that met all the given criteria.\") ||\n // Transient failure of SignerSignEx after cert selection, typically a concurrent-signtool race\n // on the per-user crypto store; the cross-process lock above makes this rare, retry covers the rest.\n e.message.includes(\"An error occurred while attempting to load the signing certificate\")\n ) {\n log.warn(`Attempt to code sign failed, another attempt will be made in 15 seconds: ${e.message}`)\n return true\n }\n return false\n },\n })\n }\n}\n\nexport class SigntoolSignManager extends SigntoolBaseSignManager {\n protected computeWindowsSignArgs(options: WindowsSignTaskConfiguration, vm: VmManager): Array<string> {\n const signing = getSigntoolFamilyConfig(options.options)\n\n const inputFile = vm.toVmFile(options.path)\n const args = [\"sign\"]\n\n // Timestamping\n if (!isOfflineModeEnabled()) {\n const isRfc3161 = options.isNest || options.hash === \"sha256\"\n args.push(isRfc3161 ? \"/tr\" : \"/t\")\n const timestampUrl = isRfc3161 ? signing?.rfc3161TimeStampServer || \"http://timestamp.digicert.com\" : signing?.timeStampServer || \"http://timestamp.digicert.com\"\n args.push(timestampUrl)\n }\n\n // Certificate\n this.addCertificateArgs(args, options, vm, true)\n\n // Hash algorithm\n if (this.isLegacyToolset()) {\n // Legacy v0.0.0: Only add /fd for non-SHA1 (original behavior)\n if (options.hash !== \"sha1\") {\n args.push(\"/fd\", options.hash)\n if (!isOfflineModeEnabled()) {\n args.push(\"/td\", \"sha256\")\n }\n }\n } else {\n // Modern: Always add /fd (required by new Windows Kits)\n args.push(\"/fd\", options.hash.toLowerCase())\n // Only add /td for RFC3161 timestamps (incompatible with /t)\n if (!isOfflineModeEnabled() && (options.isNest || options.hash === \"sha256\")) {\n args.push(\"/td\", \"sha256\")\n }\n }\n\n // Optional parameters\n this.addCommonSigningArgs(args, options, vm, true)\n\n // Windows-specific\n args.push(\"/debug\")\n args.push(inputFile) // Must be last\n\n return args\n }\n\n protected computeOsslsigncodeArgs(options: WindowsSignTaskConfiguration, vm: VmManager): Array<string> {\n const signing = getSigntoolFamilyConfig(options.options)\n\n const inputFile = vm.toVmFile(options.path)\n const outputPath = this.getOutputPath(inputFile, options.hash)\n options.resultOutputPath = outputPath\n\n const args = [\"sign\", \"-in\", inputFile, \"-out\", outputPath]\n\n // Timestamping\n if (!isOfflineModeEnabled()) {\n const timestampUrl = signing?.timeStampServer || \"http://timestamp.digicert.com\"\n args.push(\"-t\", timestampUrl)\n }\n\n // Certificate file\n this.addCertificateArgs(args, options, vm, false)\n\n // Hash algorithm\n args.push(\"-h\", options.hash.toLowerCase())\n\n // Optional parameters (name, site, nest, password, additionalCert)\n this.addCommonSigningArgs(args, options, vm, false)\n\n // Proxy support\n const httpsProxy = process.env.HTTPS_PROXY\n if (httpsProxy?.length) {\n args.push(\"-p\", httpsProxy)\n }\n\n return args\n }\n}\n\n/**\n * The hash algorithms to sign `filePath` with, one signing pass each.\n *\n * - `.msi` holds a single signature, so it is signed once: with `sha256` unless `sha1` is the only algorithm requested.\n * - `.appx`, `.msix` and `.msixbundle` are always `sha256`.\n * - Everything else uses the configured list, defaulting to dual signing with `sha1` then `sha256`.\n *\n * Extensions are matched case-insensitively (`app.MSI` is an MSI). An empty list is a configuration error: it would\n * run no signing pass while the file is still reported as signed.\n */\nexport function resolveSigningHashAlgorithms(filePath: string, configured: Array<\"sha1\" | \"sha256\"> | \"sha1\" | \"sha256\" | null | undefined): Array<\"sha1\" | \"sha256\"> {\n const requested = configured == null ? null : asArray(configured)\n if (requested != null && requested.length === 0) {\n throw new InvalidConfigurationError(\n `win.sign.signingHashAlgorithms is an empty list, so no signing pass would run. List at least one of \"sha1\" or \"sha256\", remove the option to use the default [\"sha1\", \"sha256\"], or set win.sign to false to disable Windows signing.`\n )\n }\n const ext = path.extname(filePath).toLowerCase()\n if (ext === \".msi\") {\n return [requested != null && !requested.includes(\"sha256\") ? \"sha1\" : \"sha256\"]\n }\n if (ext === \".appx\" || ext === \".msix\" || ext === \".msixbundle\") {\n return [\"sha256\"]\n }\n return requested ?? [\"sha1\", \"sha256\"]\n}\n"]}
|