app-builder-lib 27.0.0-alpha.12 → 27.0.0-alpha.13

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.
Files changed (220) hide show
  1. package/dist/asar/asarUtil.js +1 -1
  2. package/dist/asar/asarUtil.js.map +1 -1
  3. package/dist/codeSign/certInfo.d.ts +4 -1
  4. package/dist/codeSign/certInfo.d.ts.map +1 -1
  5. package/dist/codeSign/certInfo.js +5 -3
  6. package/dist/codeSign/certInfo.js.map +1 -1
  7. package/dist/codeSign/forceCodeSigning.d.ts +22 -0
  8. package/dist/codeSign/forceCodeSigning.d.ts.map +1 -0
  9. package/dist/codeSign/forceCodeSigning.js +18 -0
  10. package/dist/codeSign/forceCodeSigning.js.map +1 -0
  11. package/dist/codeSign/mac/macCodeSign.d.ts +13 -1
  12. package/dist/codeSign/mac/macCodeSign.d.ts.map +1 -1
  13. package/dist/codeSign/mac/macCodeSign.js +29 -2
  14. package/dist/codeSign/mac/macCodeSign.js.map +1 -1
  15. package/dist/codeSign/mac/macSignatureVerifier.d.ts +23 -0
  16. package/dist/codeSign/mac/macSignatureVerifier.d.ts.map +1 -0
  17. package/dist/codeSign/mac/macSignatureVerifier.js +96 -0
  18. package/dist/codeSign/mac/macSignatureVerifier.js.map +1 -0
  19. package/dist/codeSign/win/authenticodeSignature.d.ts +14 -2
  20. package/dist/codeSign/win/authenticodeSignature.d.ts.map +1 -1
  21. package/dist/codeSign/win/authenticodeSignature.js +78 -30
  22. package/dist/codeSign/win/authenticodeSignature.js.map +1 -1
  23. package/dist/codeSign/win/pkcs11SignManager.d.ts.map +1 -1
  24. package/dist/codeSign/win/pkcs11SignManager.js +4 -3
  25. package/dist/codeSign/win/pkcs11SignManager.js.map +1 -1
  26. package/dist/codeSign/win/publisherName.d.ts +31 -0
  27. package/dist/codeSign/win/publisherName.d.ts.map +1 -0
  28. package/dist/codeSign/win/publisherName.js +78 -0
  29. package/dist/codeSign/win/publisherName.js.map +1 -0
  30. package/dist/codeSign/win/signtoolBaseSignManager.d.ts +16 -9
  31. package/dist/codeSign/win/signtoolBaseSignManager.d.ts.map +1 -1
  32. package/dist/codeSign/win/signtoolBaseSignManager.js +46 -35
  33. package/dist/codeSign/win/signtoolBaseSignManager.js.map +1 -1
  34. package/dist/codeSign/win/verifyUpdatePublisher.d.ts.map +1 -1
  35. package/dist/codeSign/win/verifyUpdatePublisher.js +7 -4
  36. package/dist/codeSign/win/verifyUpdatePublisher.js.map +1 -1
  37. package/dist/codeSign/win/windowsSignAzureManager.d.ts +1 -1
  38. package/dist/codeSign/win/windowsSignAzureManager.d.ts.map +1 -1
  39. package/dist/codeSign/win/windowsSignAzureManager.js +24 -6
  40. package/dist/codeSign/win/windowsSignAzureManager.js.map +1 -1
  41. package/dist/configuration.d.ts +46 -3
  42. package/dist/configuration.d.ts.map +1 -1
  43. package/dist/configuration.js.map +1 -1
  44. package/dist/electron/mac/asarIntegrityDigest.js +2 -2
  45. package/dist/electron/mac/asarIntegrityDigest.js.map +1 -1
  46. package/dist/electron/mac/electronMacUtils.d.ts +3 -2
  47. package/dist/electron/mac/electronMacUtils.d.ts.map +1 -1
  48. package/dist/electron/mac/electronMacUtils.js +3 -2
  49. package/dist/electron/mac/electronMacUtils.js.map +1 -1
  50. package/dist/fileMatcher.d.ts.map +1 -1
  51. package/dist/fileMatcher.js +4 -2
  52. package/dist/fileMatcher.js.map +1 -1
  53. package/dist/index.d.ts +1 -1
  54. package/dist/index.d.ts.map +1 -1
  55. package/dist/index.js +4 -3
  56. package/dist/index.js.map +1 -1
  57. package/dist/indexInternal.d.ts +7 -2
  58. package/dist/indexInternal.d.ts.map +1 -1
  59. package/dist/indexInternal.js +6 -2
  60. package/dist/indexInternal.js.map +1 -1
  61. package/dist/linuxPackager.js +1 -1
  62. package/dist/linuxPackager.js.map +1 -1
  63. package/dist/macPackager.d.ts +26 -0
  64. package/dist/macPackager.d.ts.map +1 -1
  65. package/dist/macPackager.js +168 -12
  66. package/dist/macPackager.js.map +1 -1
  67. package/dist/options/PlatformSpecificBuildOptions.d.ts +15 -12
  68. package/dist/options/PlatformSpecificBuildOptions.d.ts.map +1 -1
  69. package/dist/options/PlatformSpecificBuildOptions.js.map +1 -1
  70. package/dist/options/SquirrelWindowsOptions.d.ts +3 -0
  71. package/dist/options/SquirrelWindowsOptions.d.ts.map +1 -1
  72. package/dist/options/SquirrelWindowsOptions.js.map +1 -1
  73. package/dist/options/macOptions.d.ts +7 -2
  74. package/dist/options/macOptions.d.ts.map +1 -1
  75. package/dist/options/macOptions.js.map +1 -1
  76. package/dist/options/winOptions.d.ts +61 -15
  77. package/dist/options/winOptions.d.ts.map +1 -1
  78. package/dist/options/winOptions.js +20 -0
  79. package/dist/options/winOptions.js.map +1 -1
  80. package/dist/packager.d.ts +1 -0
  81. package/dist/packager.d.ts.map +1 -1
  82. package/dist/packager.js +7 -2
  83. package/dist/packager.js.map +1 -1
  84. package/dist/platformPackager.d.ts +14 -5
  85. package/dist/platformPackager.d.ts.map +1 -1
  86. package/dist/platformPackager.js +44 -13
  87. package/dist/platformPackager.js.map +1 -1
  88. package/dist/publish/PublishManager.d.ts +3 -0
  89. package/dist/publish/PublishManager.d.ts.map +1 -1
  90. package/dist/publish/PublishManager.js +50 -16
  91. package/dist/publish/PublishManager.js.map +1 -1
  92. package/dist/publish/manifestUploadCheck.d.ts +10 -0
  93. package/dist/publish/manifestUploadCheck.d.ts.map +1 -0
  94. package/dist/publish/manifestUploadCheck.js +75 -0
  95. package/dist/publish/manifestUploadCheck.js.map +1 -0
  96. package/dist/publish/updateInfoBuilder.d.ts.map +1 -1
  97. package/dist/publish/updateInfoBuilder.js +51 -17
  98. package/dist/publish/updateInfoBuilder.js.map +1 -1
  99. package/dist/publish/updateManifestVerifier.d.ts +22 -0
  100. package/dist/publish/updateManifestVerifier.d.ts.map +1 -0
  101. package/dist/publish/updateManifestVerifier.js +65 -0
  102. package/dist/publish/updateManifestVerifier.js.map +1 -0
  103. package/dist/targets/ArchiveTarget.d.ts.map +1 -1
  104. package/dist/targets/ArchiveTarget.js +6 -2
  105. package/dist/targets/ArchiveTarget.js.map +1 -1
  106. package/dist/targets/archive.d.ts.map +1 -1
  107. package/dist/targets/archive.js +3 -3
  108. package/dist/targets/archive.js.map +1 -1
  109. package/dist/targets/linux/FlatpakTarget.js +5 -5
  110. package/dist/targets/linux/FlatpakTarget.js.map +1 -1
  111. package/dist/targets/linux/FpmTarget.d.ts.map +1 -1
  112. package/dist/targets/linux/FpmTarget.js +10 -7
  113. package/dist/targets/linux/FpmTarget.js.map +1 -1
  114. package/dist/targets/linux/LinuxTargetHelper.js +1 -1
  115. package/dist/targets/linux/LinuxTargetHelper.js.map +1 -1
  116. package/dist/targets/linux/appimage/AppImageTarget.d.ts.map +1 -1
  117. package/dist/targets/linux/appimage/AppImageTarget.js +6 -1
  118. package/dist/targets/linux/appimage/AppImageTarget.js.map +1 -1
  119. package/dist/targets/linux/appimage/appImageUtil.js +9 -9
  120. package/dist/targets/linux/appimage/appImageUtil.js.map +1 -1
  121. package/dist/targets/linux/flatpakBundle.d.ts.map +1 -1
  122. package/dist/targets/linux/flatpakBundle.js +25 -20
  123. package/dist/targets/linux/flatpakBundle.js.map +1 -1
  124. package/dist/targets/linux/snap/coreLegacy.d.ts.map +1 -1
  125. package/dist/targets/linux/snap/coreLegacy.js +22 -6
  126. package/dist/targets/linux/snap/coreLegacy.js.map +1 -1
  127. package/dist/targets/linux/snap/snapPlugs.d.ts +2 -2
  128. package/dist/targets/linux/snap/snapPlugs.d.ts.map +1 -1
  129. package/dist/targets/linux/snap/snapPlugs.js +1 -1
  130. package/dist/targets/linux/snap/snapPlugs.js.map +1 -1
  131. package/dist/targets/linux/snap/snapcraftBuilder.d.ts.map +1 -1
  132. package/dist/targets/linux/snap/snapcraftBuilder.js +19 -17
  133. package/dist/targets/linux/snap/snapcraftBuilder.js.map +1 -1
  134. package/dist/targets/mac/MacTargetHelper.d.ts +15 -3
  135. package/dist/targets/mac/MacTargetHelper.d.ts.map +1 -1
  136. package/dist/targets/mac/MacTargetHelper.js +96 -13
  137. package/dist/targets/mac/MacTargetHelper.js.map +1 -1
  138. package/dist/targets/mac/pkg.d.ts.map +1 -1
  139. package/dist/targets/mac/pkg.js +7 -5
  140. package/dist/targets/mac/pkg.js.map +1 -1
  141. package/dist/targets/win/nsis/NsisTarget.d.ts.map +1 -1
  142. package/dist/targets/win/nsis/NsisTarget.js +8 -2
  143. package/dist/targets/win/nsis/NsisTarget.js.map +1 -1
  144. package/dist/targets/win/nsis/nsisOptions.d.ts +1 -1
  145. package/dist/targets/win/nsis/nsisOptions.js.map +1 -1
  146. package/dist/toolsets/nsis.js +1 -1
  147. package/dist/toolsets/nsis.js.map +1 -1
  148. package/dist/toolsets/wine.d.ts +3 -0
  149. package/dist/toolsets/wine.d.ts.map +1 -1
  150. package/dist/toolsets/wine.js +14 -5
  151. package/dist/toolsets/wine.js.map +1 -1
  152. package/dist/util/appFileCopier.d.ts.map +1 -1
  153. package/dist/util/appFileCopier.js +9 -3
  154. package/dist/util/appFileCopier.js.map +1 -1
  155. package/dist/util/buildOutputVerifier.d.ts +40 -0
  156. package/dist/util/buildOutputVerifier.d.ts.map +1 -0
  157. package/dist/util/buildOutputVerifier.js +420 -0
  158. package/dist/util/buildOutputVerifier.js.map +1 -0
  159. package/dist/util/config/fileOptions.js +2 -2
  160. package/dist/util/config/fileOptions.js.map +1 -1
  161. package/dist/util/config/legacyConfigGuard.d.ts.map +1 -1
  162. package/dist/util/config/legacyConfigGuard.js +2 -2
  163. package/dist/util/config/legacyConfigGuard.js.map +1 -1
  164. package/dist/util/config/legacyOptions.d.ts +9 -2
  165. package/dist/util/config/legacyOptions.d.ts.map +1 -1
  166. package/dist/util/config/legacyOptions.js +8 -2
  167. package/dist/util/config/legacyOptions.js.map +1 -1
  168. package/dist/util/electronGet.d.ts.map +1 -1
  169. package/dist/util/electronGet.js +3 -1
  170. package/dist/util/electronGet.js.map +1 -1
  171. package/dist/util/flags.d.ts.map +1 -1
  172. package/dist/util/flags.js +3 -9
  173. package/dist/util/flags.js.map +1 -1
  174. package/dist/util/mac/macosIconComposer.d.ts.map +1 -1
  175. package/dist/util/mac/macosIconComposer.js +6 -5
  176. package/dist/util/mac/macosIconComposer.js.map +1 -1
  177. package/dist/util/macroExpander.js +1 -1
  178. package/dist/util/macroExpander.js.map +1 -1
  179. package/dist/util/nativeBinaryVerifier.d.ts.map +1 -1
  180. package/dist/util/nativeBinaryVerifier.js +3 -1
  181. package/dist/util/nativeBinaryVerifier.js.map +1 -1
  182. package/dist/util/packageMetadata.js +1 -1
  183. package/dist/util/packageMetadata.js.map +1 -1
  184. package/dist/util/removedEnvVars.d.ts +2 -0
  185. package/dist/util/removedEnvVars.d.ts.map +1 -1
  186. package/dist/util/removedEnvVars.js +15 -1
  187. package/dist/util/removedEnvVars.js.map +1 -1
  188. package/dist/util/streamSpawnToFile.d.ts +3 -1
  189. package/dist/util/streamSpawnToFile.d.ts.map +1 -1
  190. package/dist/util/streamSpawnToFile.js +6 -2
  191. package/dist/util/streamSpawnToFile.js.map +1 -1
  192. package/dist/version.d.ts +1 -1
  193. package/dist/version.js +1 -1
  194. package/dist/version.js.map +1 -1
  195. package/dist/vm/ParallelsVm.d.ts +10 -0
  196. package/dist/vm/ParallelsVm.d.ts.map +1 -1
  197. package/dist/vm/ParallelsVm.js +22 -8
  198. package/dist/vm/ParallelsVm.js.map +1 -1
  199. package/dist/vm/PwshVm.d.ts +0 -1
  200. package/dist/vm/PwshVm.d.ts.map +1 -1
  201. package/dist/vm/PwshVm.js +10 -15
  202. package/dist/vm/PwshVm.js.map +1 -1
  203. package/dist/vm/WineVm.d.ts.map +1 -1
  204. package/dist/vm/WineVm.js +4 -4
  205. package/dist/vm/WineVm.js.map +1 -1
  206. package/dist/vm/vm.d.ts +9 -3
  207. package/dist/vm/vm.d.ts.map +1 -1
  208. package/dist/vm/vm.js +40 -32
  209. package/dist/vm/vm.js.map +1 -1
  210. package/dist/winPackager.d.ts +16 -1
  211. package/dist/winPackager.d.ts.map +1 -1
  212. package/dist/winPackager.js +77 -19
  213. package/dist/winPackager.js.map +1 -1
  214. package/package.json +9 -9
  215. package/scheme.json +497 -23
  216. package/templates/nsis/include/allowOnlyOneInstallerInstance.nsh +14 -9
  217. package/dist/vm/MonoVm.d.ts +0 -9
  218. package/dist/vm/MonoVm.d.ts.map +0 -1
  219. package/dist/vm/MonoVm.js +0 -16
  220. package/dist/vm/MonoVm.js.map +0 -1
@@ -1 +1 @@
1
- {"version":3,"file":"authenticodeSignature.js","sourceRoot":"","sources":["../../../src/codeSign/win/authenticodeSignature.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,MAAM,MAAM,QAAQ,CAAA;AAChC,OAAO,EAAE,4BAA4B,EAAE,gCAAgC,EAAE,qBAAqB,EAAE,MAAM,sBAAsB,CAAA;AAC5H,OAAO,EAAE,QAAQ,EAAE,MAAM,eAAe,CAAA;AACxC,OAAO,EAAE,IAAI,EAAE,MAAM,aAAa,CAAA;AAClC,OAAO,KAAK,KAAK,MAAM,OAAO,CAAA;AAE9B;;;GAGG;AACH,MAAM,CAAC,MAAM,2BAA2B,GAAG;IACzC,KAAK,EAAE,CAAC;IACR,YAAY,EAAE,CAAC;IACf,SAAS,EAAE,CAAC;IACZ,YAAY,EAAE,CAAC;IACf,UAAU,EAAE,CAAC;IACb,sBAAsB,EAAE,CAAC;IACzB,YAAY,EAAE,CAAC;CACP,CAAA;AAEV,6HAA6H;AAC7H,MAAM,UAAU,+BAA+B,CAAC,MAAqB;IACnE,IAAI,MAAM,IAAI,IAAI,EAAE,CAAC;QACnB,OAAO,SAAS,CAAA;IAClB,CAAC;IACD,KAAK,MAAM,CAAC,IAAI,EAAE,KAAK,CAAC,IAAI,MAAM,CAAC,OAAO,CAAC,2BAA2B,CAAC,EAAE,CAAC;QACxE,IAAI,KAAK,KAAK,MAAM,EAAE,CAAC;YACrB,OAAO,IAAI,CAAA;QACb,CAAC;IACH,CAAC;IACD,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,eAAe,KAAK,8BAA8B,EAAE,CAAC;YAC5D,OAAO,EAAE,IAAI,EAAE,YAAY,EAAE,MAAM,EAAE,sCAAsC,IAAI,CAAC,eAAe,CAAC,QAAQ,CAAC,EAAE,CAAC,EAAE,EAAE,CAAA;QAClH,CAAC;QACD,OAAO,EAAE,IAAI,EAAE,QAAQ,EAAE,OAAO,EAAE,sBAAsB,CAAC,IAAI,CAAC,IAAI,CAAC,EAAE,MAAM,EAAE,IAAI,EAAE,CAAA;IACrF,CAAC;IAAC,OAAO,CAAM,EAAE,CAAC;QAChB,OAAO,EAAE,IAAI,EAAE,YAAY,EAAE,MAAM,EAAE,CAAC,CAAC,OAAO,IAAI,MAAM,CAAC,CAAC,CAAC,EAAE,CAAA;IAC/D,CAAC;AACH,CAAC","sourcesContent":["import * as asn1js from \"asn1js\"\nimport { escapePowerShellSingleQuotes, parseAuthenticodeSignatureOutput, preparePowerShellExec } from \"builder-util-runtime\"\nimport { execFile } from \"child_process\"\nimport { open } from \"fs/promises\"\nimport * as pkijs from \"pkijs\"\n\n/**\n * Values of `System.Management.Automation.SignatureStatus`. `ConvertTo-Json` serializes the enum as its numeric\n * value, which is the representation {@link AuthenticodeSignerInfo} carries.\n */\nexport const AuthenticodeSignatureStatus = {\n Valid: 0,\n UnknownError: 1,\n NotSigned: 2,\n HashMismatch: 3,\n NotTrusted: 4,\n NotSupportedFileFormat: 5,\n Incompatible: 6,\n} as const\n\n/** Returns the `SignatureStatus` name of a numeric status (e.g. `HashMismatch` for 3), or the number itself when unknown. */\nexport function authenticodeSignatureStatusName(status: number | null): string {\n if (status == null) {\n return \"unknown\"\n }\n for (const [name, value] of Object.entries(AuthenticodeSignatureStatus)) {\n if (value === status) {\n return name\n }\n }\n return String(status)\n}\n\n/**\n * The embedded Authenticode signature of a Windows executable, as far as the update signature check needs it:\n * - `signed` — the subject of the certificate that made the (primary) signature, in the format Windows reports it\n * (`X509Certificate2.Subject`), plus the numeric `SignatureStatus` (see {@link AuthenticodeSignatureStatus}) when\n * the host can verify it (Windows only)\n * - `unsigned` — the file has no embedded signature\n * - `unreadable` — the signature could not be read (`reason` says why)\n */\nexport type AuthenticodeSignerInfo =\n | { readonly type: \"signed\"; readonly subject: string; readonly status: number | null }\n | { readonly type: \"unsigned\"; readonly reason: string }\n | { readonly type: \"unreadable\"; readonly reason: string }\n\nexport type AuthenticodeSignerReader = (file: string) => Promise<AuthenticodeSignerInfo>\n\n/**\n * Reads the signer of a Windows executable's embedded Authenticode signature: on Windows with\n * `Get-AuthenticodeSignature`, the very API electron-updater verifies downloaded updates with; elsewhere by parsing\n * the PE certificate table and its PKCS#7 signature directly (no external tool needed).\n */\nexport function readAuthenticodeSigner(file: string): Promise<AuthenticodeSignerInfo> {\n return process.platform === \"win32\" ? readAuthenticodeSignerWithPowerShell(file) : readEmbeddedAuthenticodeSigner(file)\n}\n\n// ─── Windows: Get-AuthenticodeSignature ──────────────────────────────────────\n\n/**\n * Reads the signer with `Get-AuthenticodeSignature`, with the helpers electron-updater verifies downloaded updates\n * with (builder-util-runtime: the same PowerShell invocation, path escaping and JSON parsing), so the build sees\n * exactly what the updater will see.\n */\nexport function readAuthenticodeSignerWithPowerShell(file: string): Promise<AuthenticodeSignerInfo> {\n const escapedFile = escapePowerShellSingleQuotes(file)\n return new Promise<AuthenticodeSignerInfo>(resolve => {\n // longer than the updater's 20s: a busy build machine may still be preparing the PowerShell modules on first use,\n // and a timeout here fails the build\n execFile(...preparePowerShellExec(`Get-AuthenticodeSignature -LiteralPath '${escapedFile}' | ConvertTo-Json -Compress`, 60 * 1000), (error, stdout, stderr) => {\n if (error != null) {\n const stderrText = String(stderr ?? \"\").trim()\n resolve({ type: \"unreadable\", reason: `Get-AuthenticodeSignature failed: ${error.message}${stderrText.length > 0 ? `\\n${stderrText}` : \"\"}` })\n return\n }\n let data: unknown\n try {\n data = parseAuthenticodeSignatureOutput(stdout)\n } catch (e: any) {\n resolve({ type: \"unreadable\", reason: `cannot parse Get-AuthenticodeSignature output (${e.message}): ${stdout}` })\n return\n }\n const status = getProperty(data, \"Status\")\n const numericStatus = typeof status === \"number\" ? status : null\n const subject = getProperty(getProperty(data, \"SignerCertificate\"), \"Subject\")\n if (typeof subject !== \"string\") {\n resolve({ type: \"unsigned\", reason: `Get-AuthenticodeSignature reports no signer certificate (status: ${authenticodeSignatureStatusName(numericStatus)})` })\n return\n }\n resolve({ type: \"signed\", subject, status: numericStatus })\n })\n })\n}\n\nfunction getProperty(value: unknown, name: string): unknown {\n return value != null && typeof value === \"object\" && name in value ? Reflect.get(value, name) : undefined\n}\n\n// ─── Windows subject format ─────────────────────────────────────────────────\n\n// Maps certificate attribute OIDs to the X.500 names Windows uses when it formats a certificate subject\n// (CertNameToStr with CERT_X500_NAME_STR, i.e. `X509Certificate2.Subject` as Get-AuthenticodeSignature reports it).\n// Other OIDs are written as `OID.<dotted oid>`, as Windows does (e.g. `OID.2.5.4.15` in EV certificates).\nconst WINDOWS_ATTRIBUTE_TYPE_NAMES: Record<string, string> = {\n \"2.5.4.3\": \"CN\",\n \"2.5.4.4\": \"SN\",\n \"2.5.4.5\": \"SERIALNUMBER\",\n \"2.5.4.6\": \"C\",\n \"2.5.4.7\": \"L\",\n \"2.5.4.8\": \"S\",\n \"2.5.4.9\": \"STREET\",\n \"2.5.4.10\": \"O\",\n \"2.5.4.11\": \"OU\",\n \"2.5.4.12\": \"T\",\n \"2.5.4.13\": \"Description\",\n \"2.5.4.17\": \"PostalCode\",\n \"2.5.4.18\": \"POBox\",\n \"2.5.4.20\": \"Phone\",\n \"2.5.4.24\": \"X21Address\",\n \"2.5.4.42\": \"G\",\n \"2.5.4.43\": \"I\",\n \"2.5.4.46\": \"dnQualifier\",\n \"1.2.840.113549.1.9.1\": \"E\",\n \"0.9.2342.19200300.100.1.25\": \"DC\",\n}\n\n// Windows quotes an RDN value that has leading/trailing white space or contains one of these characters,\n// doubling embedded quotes.\nconst NEEDS_WINDOWS_DN_QUOTING = /[,+=\"\\n<>#;]/\n\nfunction quoteWindowsDnValue(value: string): string {\n if (value.length === 0 || value !== value.trim() || NEEDS_WINDOWS_DN_QUOTING.test(value)) {\n return `\"${value.replace(/\"/g, '\"\"')}\"`\n }\n return value\n}\n\n/**\n * Formats a certificate name the way Windows reports a certificate subject (`X509Certificate2.Subject`, which\n * electron-updater compares the configured publisher names against): RDNs in reverse encoding order separated by\n * `, `, with the Windows X.500 attribute names (e.g. `S` for the state, not `ST`).\n */\nexport function formatWindowsSubjectDn(name: pkijs.RelativeDistinguishedNames): string {\n return name.typesAndValues\n .map(attribute => {\n const typeName = WINDOWS_ATTRIBUTE_TYPE_NAMES[attribute.type] ?? `OID.${attribute.type}`\n return `${typeName}=${quoteWindowsDnValue(String(attribute.value.valueBlock.value))}`\n })\n .reverse()\n .join(\", \")\n}\n\n// ─── Any host: PE certificate table + PKCS#7 ────────────────────────────────\n\nconst WIN_CERT_TYPE_PKCS_SIGNED_DATA = 0x0002\n// The certificate table of a signed installer is a few KB; anything this large is not a real signature.\nconst MAX_CERTIFICATE_TABLE_SIZE = 16 * 1024 * 1024\n\nasync function readExactly(handle: Awaited<ReturnType<typeof open>>, position: number, length: number): Promise<Buffer> {\n const buffer = Buffer.alloc(length)\n const { bytesRead } = await handle.read(buffer, 0, length, position)\n if (bytesRead !== length) {\n throw new Error(`unexpected end of file reading ${length} bytes at offset ${position}`)\n }\n return buffer\n}\n\n/**\n * Returns the first `WIN_CERTIFICATE` entry of a PE file's certificate table (the primary Authenticode signature,\n * which is the one Windows reports), or null when the file has no certificate table. Only the headers and the table\n * itself are read, never the whole (possibly huge) installer.\n */\nexport async function readPeSignatureBlob(file: string): Promise<{ certificateType: number; data: Buffer } | null> {\n const handle = await open(file, \"r\")\n try {\n const { size: fileSize } = await handle.stat()\n const dosHeader = await readExactly(handle, 0, 64)\n if (dosHeader.toString(\"latin1\", 0, 2) !== \"MZ\") {\n throw new Error(\"not a PE file (no MZ header)\")\n }\n const peHeaderOffset = dosHeader.readUInt32LE(0x3c)\n // PE signature (4) + COFF file header (20)\n const peHeader = await readExactly(handle, peHeaderOffset, 24)\n if (peHeader.toString(\"latin1\", 0, 4) !== \"PE\\0\\0\") {\n throw new Error(\"not a PE file (no PE signature)\")\n }\n const optionalHeaderSize = peHeader.readUInt16LE(20)\n const optionalHeader = await readExactly(handle, peHeaderOffset + 24, optionalHeaderSize)\n const magic = optionalHeader.readUInt16LE(0)\n // PE32 / PE32+: offset of NumberOfRvaAndSizes; the data directories follow it\n const rvaCountOffset = magic === 0x10b ? 92 : magic === 0x20b ? 108 : -1\n if (rvaCountOffset === -1) {\n throw new Error(`unknown optional header magic 0x${magic.toString(16)}`)\n }\n // the certificate table is data directory #4; each entry is VirtualAddress (u32) + Size (u32)\n const securityDirectoryOffset = rvaCountOffset + 4 + 4 * 8\n if (optionalHeader.length < securityDirectoryOffset + 8 || optionalHeader.readUInt32LE(rvaCountOffset) <= 4) {\n return null\n }\n // for the certificate table, VirtualAddress is a file offset\n const tableOffset = optionalHeader.readUInt32LE(securityDirectoryOffset)\n const tableSize = optionalHeader.readUInt32LE(securityDirectoryOffset + 4)\n if (tableOffset === 0 || tableSize === 0) {\n return null\n }\n if (tableSize < 8 || tableSize > MAX_CERTIFICATE_TABLE_SIZE || tableOffset + tableSize > fileSize) {\n throw new Error(`invalid certificate table (offset ${tableOffset}, size ${tableSize}, file size ${fileSize})`)\n }\n const table = await readExactly(handle, tableOffset, tableSize)\n // WIN_CERTIFICATE: dwLength (u32, includes this 8-byte header), wRevision (u16), wCertificateType (u16), bCertificate\n const entryLength = table.readUInt32LE(0)\n if (entryLength < 8 || entryLength > tableSize) {\n throw new Error(`invalid WIN_CERTIFICATE length ${entryLength}`)\n }\n return { certificateType: table.readUInt16LE(6), data: table.subarray(8, entryLength) }\n } finally {\n await handle.close()\n }\n}\n\nfunction toArrayBuffer(buffer: Buffer): ArrayBuffer {\n const result = new ArrayBuffer(buffer.byteLength)\n new Uint8Array(result).set(buffer)\n return result\n}\n\n/**\n * Returns the subject of the certificate that made the first signer's signature in a DER-encoded PKCS#7 SignedData\n * (`ContentInfo`), formatted the way Windows reports it.\n */\nexport function readPkcs7SignerSubject(der: Buffer): string {\n const asn1 = asn1js.fromBER(toArrayBuffer(der))\n if (asn1.offset === -1) {\n throw new Error(\"invalid PKCS#7 encoding\")\n }\n const contentInfo = new pkijs.ContentInfo({ schema: asn1.result })\n if (contentInfo.contentType !== pkijs.id_ContentType_SignedData) {\n throw new Error(`unexpected PKCS#7 content type ${contentInfo.contentType}`)\n }\n const signedData = new pkijs.SignedData({ schema: contentInfo.content })\n const signerInfo = signedData.signerInfos[0]\n if (signerInfo == null) {\n throw new Error(\"PKCS#7 signature has no signer\")\n }\n const sid: unknown = signerInfo.sid\n if (!(sid instanceof pkijs.IssuerAndSerialNumber)) {\n throw new Error(\"PKCS#7 signer is not identified by issuer and serial number\")\n }\n const certificate = (signedData.certificates ?? []).find(\n (it): it is pkijs.Certificate => it instanceof pkijs.Certificate && it.issuer.isEqual(sid.issuer) && it.serialNumber.isEqual(sid.serialNumber)\n )\n if (certificate == null) {\n throw new Error(\"the signer certificate is not embedded in the PKCS#7 signature\")\n }\n return formatWindowsSubjectDn(certificate.subject)\n}\n\n/** Reads the embedded Authenticode signer of a PE file without external tools (works on any host). */\nexport async function readEmbeddedAuthenticodeSigner(file: string): Promise<AuthenticodeSignerInfo> {\n try {\n const blob = await readPeSignatureBlob(file)\n if (blob == null) {\n return { type: \"unsigned\", reason: \"the file has no embedded Authenticode signature (empty PE certificate table)\" }\n }\n if (blob.certificateType !== WIN_CERT_TYPE_PKCS_SIGNED_DATA) {\n return { type: \"unreadable\", reason: `unsupported WIN_CERTIFICATE type 0x${blob.certificateType.toString(16)}` }\n }\n return { type: \"signed\", subject: readPkcs7SignerSubject(blob.data), status: null }\n } catch (e: any) {\n return { type: \"unreadable\", reason: e.message || String(e) }\n }\n}\n"]}
1
+ {"version":3,"file":"authenticodeSignature.js","sourceRoot":"","sources":["../../../src/codeSign/win/authenticodeSignature.ts"],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CAAC;IACD,OAAO,sBAAsB,CAAC,WAAW,CAAC,OAAO,CAAC,CAAA;AACpD,CAAC;AAED,sGAAsG;AACtG,MAAM,CAAC,KAAK,UAAU,8BAA8B,CAAC,IAAY;IAC/D,IAAI,CAAC;QACH,MAAM,IAAI,GAAG,MAAM,mBAAmB,CAAC,IAAI,CAAC,CAAA;QAC5C,IAAI,IAAI,IAAI,IAAI,EAAE,CAAC;YACjB,OAAO,EAAE,IAAI,EAAE,UAAU,EAAE,MAAM,EAAE,8EAA8E,EAAE,CAAA;QACrH,CAAC;QACD,IAAI,IAAI,CAAC,eAAe,KAAK,8BAA8B,EAAE,CAAC;YAC5D,OAAO,EAAE,IAAI,EAAE,YAAY,EAAE,MAAM,EAAE,sCAAsC,IAAI,CAAC,eAAe,CAAC,QAAQ,CAAC,EAAE,CAAC,EAAE,EAAE,CAAA;QAClH,CAAC;QACD,OAAO,EAAE,IAAI,EAAE,QAAQ,EAAE,OAAO,EAAE,sBAAsB,CAAC,IAAI,CAAC,IAAI,CAAC,EAAE,MAAM,EAAE,IAAI,EAAE,CAAA;IACrF,CAAC;IAAC,OAAO,CAAM,EAAE,CAAC;QAChB,OAAO,EAAE,IAAI,EAAE,YAAY,EAAE,MAAM,EAAE,CAAC,CAAC,OAAO,IAAI,MAAM,CAAC,CAAC,CAAC,EAAE,CAAA;IAC/D,CAAC;AACH,CAAC","sourcesContent":["import * as asn1js from \"asn1js\"\nimport { Executables, stripSensitiveEnvVars } from \"builder-util\"\nimport { parseAuthenticodeSignatureOutput, prepareAuthenticodeSignatureExec } from \"builder-util-runtime\"\nimport { execFile } from \"child_process\"\nimport { open } from \"fs/promises\"\nimport * as path from \"path\"\nimport * as pkijs from \"pkijs\"\n\n/**\n * Values of `System.Management.Automation.SignatureStatus`. `ConvertTo-Json` serializes the enum as its numeric\n * value, which is the representation {@link AuthenticodeSignerInfo} carries.\n */\nexport const AuthenticodeSignatureStatus = {\n Valid: 0,\n UnknownError: 1,\n NotSigned: 2,\n HashMismatch: 3,\n NotTrusted: 4,\n NotSupportedFileFormat: 5,\n Incompatible: 6,\n} as const\n\n/** Returns the `SignatureStatus` name of a numeric status (e.g. `HashMismatch` for 3), or the number itself when unknown. */\nexport function authenticodeSignatureStatusName(status: number | null): string {\n if (status == null) {\n return \"unknown\"\n }\n for (const [name, value] of Object.entries(AuthenticodeSignatureStatus)) {\n if (value === status) {\n return name\n }\n }\n return String(status)\n}\n\n/**\n * The embedded Authenticode signature of a Windows executable, as far as the update signature check needs it:\n * - `signed` — the subject of the certificate that made the (primary) signature, in the format Windows reports it\n * (`X509Certificate2.Subject`), plus the numeric `SignatureStatus` (see {@link AuthenticodeSignatureStatus}) when\n * the host can verify it (Windows only)\n * - `unsigned` — the file has no embedded signature\n * - `unreadable` — the signature could not be read (`reason` says why)\n */\nexport type AuthenticodeSignerInfo =\n | { readonly type: \"signed\"; readonly subject: string; readonly status: number | null }\n | { readonly type: \"unsigned\"; readonly reason: string }\n | { readonly type: \"unreadable\"; readonly reason: string }\n\nexport type AuthenticodeSignerReader = (file: string) => Promise<AuthenticodeSignerInfo>\n\n/**\n * Reads the signer of a Windows executable's embedded Authenticode signature: on Windows with\n * `Get-AuthenticodeSignature`, the very API electron-updater verifies downloaded updates with; elsewhere by parsing\n * the PE certificate table and its PKCS#7 signature directly (no external tool needed).\n */\nexport function readAuthenticodeSigner(file: string): Promise<AuthenticodeSignerInfo> {\n return process.platform === \"win32\" ? readAuthenticodeSignerWithPowerShell(file) : readEmbeddedAuthenticodeSigner(file)\n}\n\n/** File types electron-builder Authenticode-signs and can read the signature of back: PE files, MSI and AppX/MSIX packages. */\nconst AUTHENTICODE_FILE_EXTENSIONS = new Set([\".exe\", \".dll\", \".node\", \".msi\", \".appx\", \".appxbundle\", \".msix\", \".msixbundle\"])\n\n/** Whether `file` is a type whose Authenticode signature can be read back (see `AUTHENTICODE_FILE_EXTENSIONS`). */\nexport function isAuthenticodeFileType(file: string): boolean {\n return AUTHENTICODE_FILE_EXTENSIONS.has(path.extname(file).toLowerCase())\n}\n\n/**\n * Why a signature read back with {@link readAuthenticodeSigner} does not count as valid, or `null` when it does. Any\n * status but `HashMismatch` is accepted: the build host may not trust the signing chain that the users' machines\n * trust, and the reader used off Windows reports no status at all.\n */\nexport function authenticodeSignatureProblem(signer: AuthenticodeSignerInfo): string | null {\n switch (signer.type) {\n case \"unsigned\":\n return `carries no Authenticode signature (${signer.reason})`\n case \"unreadable\":\n return `has an Authenticode signature that cannot be read (${signer.reason})`\n case \"signed\":\n return signer.status === AuthenticodeSignatureStatus.HashMismatch ? \"has an invalid Authenticode signature (HashMismatch: the file was modified after signing)\" : null\n }\n}\n\n// ─── Windows: Get-AuthenticodeSignature ──────────────────────────────────────\n\n/**\n * Reads the signer with `Get-AuthenticodeSignature`, with the helpers electron-updater verifies downloaded updates\n * with (builder-util-runtime: the same PowerShell invocation and JSON parsing), so the build sees exactly what the\n * updater will see. Windows PowerShell is started from `toolsets.executables.powershell` or its default location, with\n * the build's credential variables (signing passwords, tokens, keys) removed from its environment: reading a signature\n * needs none of them.\n */\nexport function readAuthenticodeSignerWithPowerShell(file: string): Promise<AuthenticodeSignerInfo> {\n return new Promise<AuthenticodeSignerInfo>(resolve => {\n try {\n // a busy build machine may still be preparing the PowerShell modules on first use, and a timeout here fails the build\n // like every PowerShell the build starts: from toolsets.executables, or its default location when that has none\n const [powershell, args, options] = prepareAuthenticodeSignatureExec(file, 60 * 1000, Executables.resolve(\"powershell\"))\n execFile(powershell, args, { ...options, env: withoutInheritedCredentials(options.env ?? {}) }, (error, stdout, stderr) => {\n if (error != null) {\n const stderrText = String(stderr ?? \"\").trim()\n // the message of a non-zero exit is \"Command failed: <the whole command line, the encoded script included>\\n<stderr>\"\n const failure = error.killed ? \"did not finish within 60s\" : typeof error.code === \"number\" ? `exited with code ${error.code}` : error.message\n resolve({ type: \"unreadable\", reason: `Get-AuthenticodeSignature failed: ${failure}${stderrText.length > 0 ? `\\n${stderrText}` : \"\"}` })\n return\n }\n let data: unknown\n try {\n data = parseAuthenticodeSignatureOutput(stdout)\n } catch (e: any) {\n const stderrText = String(stderr ?? \"\").trim()\n resolve({ type: \"unreadable\", reason: `cannot parse Get-AuthenticodeSignature output (${e.message}): ${stdout}${stderrText.length > 0 ? `\\n${stderrText}` : \"\"}` })\n return\n }\n const status = getProperty(data, \"Status\")\n const numericStatus = typeof status === \"number\" ? status : null\n const subject = getProperty(getProperty(data, \"SignerCertificate\"), \"Subject\")\n if (typeof subject !== \"string\") {\n resolve({ type: \"unsigned\", reason: `Get-AuthenticodeSignature reports no signer certificate (status: ${authenticodeSignatureStatusName(numericStatus)})` })\n return\n }\n resolve({ type: \"signed\", subject, status: numericStatus })\n })\n } catch (e: any) {\n // PowerShell cannot be located (no executable at its toolsets.executables locations, or no default location) or started at all\n resolve({ type: \"unreadable\", reason: `Get-AuthenticodeSignature failed: ${e.message}` })\n }\n })\n}\n\n/**\n * `env` without the credential variables it inherited from the build (see `stripSensitiveEnvVars`). The variables the command\n * sets itself, such as the file to read, are kept: they are the ones whose value is not the inherited one.\n */\nfunction withoutInheritedCredentials(env: NodeJS.ProcessEnv): NodeJS.ProcessEnv {\n const result = stripSensitiveEnvVars(env)\n for (const [key, value] of Object.entries(env)) {\n if (process.env[key] !== value) {\n result[key] = value\n }\n }\n return result\n}\n\nfunction getProperty(value: unknown, name: string): unknown {\n return value != null && typeof value === \"object\" && name in value ? Reflect.get(value, name) : undefined\n}\n\n// ─── Windows subject format ─────────────────────────────────────────────────\n\n// Maps certificate attribute OIDs to the X.500 names Windows uses when it formats a certificate subject\n// (CertNameToStr with CERT_X500_NAME_STR, i.e. `X509Certificate2.Subject` as Get-AuthenticodeSignature reports it).\n// Other OIDs are written as `OID.<dotted oid>`, as Windows does (e.g. `OID.2.5.4.15` in EV certificates).\nconst WINDOWS_ATTRIBUTE_TYPE_NAMES: Record<string, string> = {\n \"2.5.4.3\": \"CN\",\n \"2.5.4.4\": \"SN\",\n \"2.5.4.5\": \"SERIALNUMBER\",\n \"2.5.4.6\": \"C\",\n \"2.5.4.7\": \"L\",\n \"2.5.4.8\": \"S\",\n \"2.5.4.9\": \"STREET\",\n \"2.5.4.10\": \"O\",\n \"2.5.4.11\": \"OU\",\n \"2.5.4.12\": \"T\",\n \"2.5.4.13\": \"Description\",\n \"2.5.4.17\": \"PostalCode\",\n \"2.5.4.18\": \"POBox\",\n \"2.5.4.20\": \"Phone\",\n \"2.5.4.24\": \"X21Address\",\n \"2.5.4.42\": \"G\",\n \"2.5.4.43\": \"I\",\n \"2.5.4.46\": \"dnQualifier\",\n \"1.2.840.113549.1.9.1\": \"E\",\n \"0.9.2342.19200300.100.1.25\": \"DC\",\n}\n\n// Windows quotes an RDN value that has leading/trailing white space or contains one of these characters,\n// doubling embedded quotes.\nconst NEEDS_WINDOWS_DN_QUOTING = /[,+=\"\\n<>#;]/\n\n/** Quotes an RDN value the way Windows does when it formats a certificate subject (see {@link formatWindowsSubjectDn}). */\nexport function quoteWindowsDnValue(value: string): string {\n if (value.length === 0 || value !== value.trim() || NEEDS_WINDOWS_DN_QUOTING.test(value)) {\n return `\"${value.replace(/\"/g, '\"\"')}\"`\n }\n return value\n}\n\n/**\n * Formats a certificate name the way Windows reports a certificate subject (`X509Certificate2.Subject`, which\n * electron-updater compares the configured publisher names against): RDNs in reverse encoding order separated by\n * `, `, with the Windows X.500 attribute names (e.g. `S` for the state, not `ST`).\n */\nexport function formatWindowsSubjectDn(name: pkijs.RelativeDistinguishedNames): string {\n return name.typesAndValues\n .map(attribute => {\n const typeName = WINDOWS_ATTRIBUTE_TYPE_NAMES[attribute.type] ?? `OID.${attribute.type}`\n return `${typeName}=${quoteWindowsDnValue(String(attribute.value.valueBlock.value))}`\n })\n .reverse()\n .join(\", \")\n}\n\n// ─── Any host: PE certificate table + PKCS#7 ────────────────────────────────\n\nconst WIN_CERT_TYPE_PKCS_SIGNED_DATA = 0x0002\n// The certificate table of a signed installer is a few KB; anything this large is not a real signature.\nconst MAX_CERTIFICATE_TABLE_SIZE = 16 * 1024 * 1024\n\nasync function readExactly(handle: Awaited<ReturnType<typeof open>>, position: number, length: number): Promise<Buffer> {\n const buffer = Buffer.alloc(length)\n const { bytesRead } = await handle.read(buffer, 0, length, position)\n if (bytesRead !== length) {\n throw new Error(`unexpected end of file reading ${length} bytes at offset ${position}`)\n }\n return buffer\n}\n\n/**\n * Returns the first `WIN_CERTIFICATE` entry of a PE file's certificate table (the primary Authenticode signature,\n * which is the one Windows reports), or null when the file has no certificate table. Only the headers and the table\n * itself are read, never the whole (possibly huge) installer.\n */\nexport async function readPeSignatureBlob(file: string): Promise<{ certificateType: number; data: Buffer } | null> {\n const handle = await open(file, \"r\")\n try {\n const { size: fileSize } = await handle.stat()\n const dosHeader = await readExactly(handle, 0, 64)\n if (dosHeader.toString(\"latin1\", 0, 2) !== \"MZ\") {\n throw new Error(\"not a PE file (no MZ header)\")\n }\n const peHeaderOffset = dosHeader.readUInt32LE(0x3c)\n // PE signature (4) + COFF file header (20)\n const peHeader = await readExactly(handle, peHeaderOffset, 24)\n if (peHeader.toString(\"latin1\", 0, 4) !== \"PE\\0\\0\") {\n throw new Error(\"not a PE file (no PE signature)\")\n }\n const optionalHeaderSize = peHeader.readUInt16LE(20)\n const optionalHeader = await readExactly(handle, peHeaderOffset + 24, optionalHeaderSize)\n const magic = optionalHeader.readUInt16LE(0)\n // PE32 / PE32+: offset of NumberOfRvaAndSizes; the data directories follow it\n const rvaCountOffset = magic === 0x10b ? 92 : magic === 0x20b ? 108 : -1\n if (rvaCountOffset === -1) {\n throw new Error(`unknown optional header magic 0x${magic.toString(16)}`)\n }\n // the certificate table is data directory #4; each entry is VirtualAddress (u32) + Size (u32)\n const securityDirectoryOffset = rvaCountOffset + 4 + 4 * 8\n if (optionalHeader.length < securityDirectoryOffset + 8 || optionalHeader.readUInt32LE(rvaCountOffset) <= 4) {\n return null\n }\n // for the certificate table, VirtualAddress is a file offset\n const tableOffset = optionalHeader.readUInt32LE(securityDirectoryOffset)\n const tableSize = optionalHeader.readUInt32LE(securityDirectoryOffset + 4)\n if (tableOffset === 0 || tableSize === 0) {\n return null\n }\n if (tableSize < 8 || tableSize > MAX_CERTIFICATE_TABLE_SIZE || tableOffset + tableSize > fileSize) {\n throw new Error(`invalid certificate table (offset ${tableOffset}, size ${tableSize}, file size ${fileSize})`)\n }\n const table = await readExactly(handle, tableOffset, tableSize)\n // WIN_CERTIFICATE: dwLength (u32, includes this 8-byte header), wRevision (u16), wCertificateType (u16), bCertificate\n const entryLength = table.readUInt32LE(0)\n if (entryLength < 8 || entryLength > tableSize) {\n throw new Error(`invalid WIN_CERTIFICATE length ${entryLength}`)\n }\n return { certificateType: table.readUInt16LE(6), data: table.subarray(8, entryLength) }\n } finally {\n await handle.close()\n }\n}\n\nfunction toArrayBuffer(buffer: Buffer): ArrayBuffer {\n const result = new ArrayBuffer(buffer.byteLength)\n new Uint8Array(result).set(buffer)\n return result\n}\n\n/**\n * Returns the subject of the certificate that made the first signer's signature in a DER-encoded PKCS#7 SignedData\n * (`ContentInfo`), formatted the way Windows reports it.\n */\nexport function readPkcs7SignerSubject(der: Buffer): string {\n const asn1 = asn1js.fromBER(toArrayBuffer(der))\n if (asn1.offset === -1) {\n throw new Error(\"invalid PKCS#7 encoding\")\n }\n const contentInfo = new pkijs.ContentInfo({ schema: asn1.result })\n if (contentInfo.contentType !== pkijs.id_ContentType_SignedData) {\n throw new Error(`unexpected PKCS#7 content type ${contentInfo.contentType}`)\n }\n const signedData = new pkijs.SignedData({ schema: contentInfo.content })\n const signerInfo = signedData.signerInfos[0]\n if (signerInfo == null) {\n throw new Error(\"PKCS#7 signature has no signer\")\n }\n const sid: unknown = signerInfo.sid\n if (!(sid instanceof pkijs.IssuerAndSerialNumber)) {\n throw new Error(\"PKCS#7 signer is not identified by issuer and serial number\")\n }\n const certificate = (signedData.certificates ?? []).find(\n (it): it is pkijs.Certificate => it instanceof pkijs.Certificate && it.issuer.isEqual(sid.issuer) && it.serialNumber.isEqual(sid.serialNumber)\n )\n if (certificate == null) {\n throw new Error(\"the signer certificate is not embedded in the PKCS#7 signature\")\n }\n return formatWindowsSubjectDn(certificate.subject)\n}\n\n/** Reads the embedded Authenticode signer of a PE file without external tools (works on any host). */\nexport async function readEmbeddedAuthenticodeSigner(file: string): Promise<AuthenticodeSignerInfo> {\n try {\n const blob = await readPeSignatureBlob(file)\n if (blob == null) {\n return { type: \"unsigned\", reason: \"the file has no embedded Authenticode signature (empty PE certificate table)\" }\n }\n if (blob.certificateType !== WIN_CERT_TYPE_PKCS_SIGNED_DATA) {\n return { type: \"unreadable\", reason: `unsupported WIN_CERTIFICATE type 0x${blob.certificateType.toString(16)}` }\n }\n return { type: \"signed\", subject: readPkcs7SignerSubject(blob.data), status: null }\n } catch (e: any) {\n return { type: \"unreadable\", reason: e.message || String(e) }\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;AAClI,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;IAsBjC,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
+ {"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;AAClI,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"}
@@ -22,11 +22,12 @@ export class Pkcs11SignManager extends SigntoolBaseSignManager {
22
22
  this.signingConfig = signing;
23
23
  // publisherName == null means "auto-discover", but for PKCS#11 without a certificateFile
24
24
  // the cert lives inside the hardware token and cannot be read at build time. The result would be
25
- // a null publisherName in app-update.yml, silently disabling updater signature verification.
25
+ // a null publisherName in app-update.yml, with which electron-updater 7 rejects every update.
26
26
  if (signing.publisherName == null && !signing.certificateFile) {
27
27
  throw new InvalidConfigurationError("PKCS#11 signing requires either `win.sign.publisherName` or `win.sign.certificateFile` to be set. " +
28
- "Without one of these the publisher name cannot be determined at build time, and auto-updater signature verification will be silently skipped. " +
29
- "Set publisherName to the CN from your signing certificate, or provide certificateFile pointing to a certificate chain file (.crt / .cer).");
28
+ "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. " +
29
+ 'Set publisherName to the subject of your signing certificate, as a distinguished name (e.g. "CN=My Company, O=My Company, C=US"), ' +
30
+ "or provide certificateFile pointing to a certificate chain file (.crt / .cer).");
30
31
  }
31
32
  }
32
33
  // PKCS#11: always proceed — the key URI is sufficient, no cert file required.
@@ -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;AAGlI,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;QAmBjB,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,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I,CAAC,OAAO,CAAC,OAAO,EAAE,CAAC;YACrB,MAAM,GAAG,GAAG,OAAO,CAAC,GAAG,CAAC,oBAAoB,IAAI,OAAO,CAAC,GAAG,CAAC,gBAAgB,CAAA;YAC5E,IAAI,GAAG,EAAE,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 { 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, silently disabling updater signature verification.\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 auto-updater signature verification will be silently skipped. \" +\n \"Set publisherName to the CN from your signing certificate, 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 (process.env.ELECTRON_BUILDER_OFFLINE !== \"true\") {\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
+ {"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;AAGlI,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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I,EAAE,OAAO,CAAC,IAAI,CAAC,WAAW,EAAE,CAAC,CAAA;QAC3C,IAAI,CAAC,oBAAoB,CAAC,IAAI,EAAE,OAAO,EAAE,EAAE,EAAE,KAAK,CAAC,CAAA;QAEnD,wFAAwF;QACxF,4FAA4F;QAC5F,IAAI,CAAC,OAAO,CAAC,OAAO,EAAE,CAAC;YACrB,MAAM,GAAG,GAAG,OAAO,CAAC,GAAG,CAAC,oBAAoB,IAAI,OAAO,CAAC,GAAG,CAAC,gBAAgB,CAAA;YAC5E,IAAI,GAAG,EAAE,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 { 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 (process.env.ELECTRON_BUILDER_OFFLINE !== \"true\") {\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"]}
@@ -0,0 +1,31 @@
1
+ import { InvalidConfigurationError } from "builder-util";
2
+ import { WindowsConfiguration } from "../../options/winOptions.js";
3
+ export declare const PUBLISHER_NAME_DN_DOCS_URL = "https://www.electron.build/docs/migration/v27-build-changes#windows-publishername-must-be-a-distinguished-name";
4
+ export declare const MISSING_PUBLISHER_NAME_DOCS_URL = "https://www.electron.build/docs/migration/v27-build-changes#missing-publishername-fails-update-verification";
5
+ /** What electron-updater 7 requires of a publisher name, for the error messages of the build. */
6
+ export declare const PUBLISHER_NAME_DN_REQUIREMENT: string;
7
+ /** The entries of a publisherName that are not a valid publisher name DN ({@link isValidPublisherNameDn}). */
8
+ export declare function invalidPublisherNames(publisherName: string | ReadonlyArray<string>): Array<unknown>;
9
+ /**
10
+ * Throws an {@link InvalidConfigurationError} when an explicitly configured publisherName has an entry that is not a
11
+ * distinguished name ({@link isValidPublisherNameDn}), which electron-updater 7 could never match. `null` / `undefined` (none /
12
+ * derive from the certificate) are not validated: a build that writes `app-update.yml` without a publisherName fails elsewhere
13
+ * ({@link missingUpdatePublisherNameError}).
14
+ */
15
+ export declare function validatePublisherNameFormat(publisherName: string | ReadonlyArray<string> | null | undefined, configKey?: string): void;
16
+ /**
17
+ * The publisher name written to `app-update.yml` when none is configured: `CN=<common name>` of the signing certificate,
18
+ * with the value quoted the way Windows quotes it in the subject it reports (`X509Certificate2.Subject`, which electron-updater
19
+ * matches against), so a common name containing e.g. `,`, `+` or `"` matches the signer's CN. Only the CN is pinned, so a
20
+ * renewed certificate whose other subject attributes change still matches; a stricter pin is an explicit publisherName.
21
+ * Throws an {@link InvalidConfigurationError} when the certificate has no common name (empty).
22
+ */
23
+ export declare function derivePublisherName(commonName: string): string;
24
+ /**
25
+ * The error for a Windows build that would write `app-update.yml` without a publisherName while update signature verification is
26
+ * enabled (`win.verifyUpdateCodeSignature` is not `false`): electron-updater 7 rejects every update of such an app. The reason names
27
+ * what left the publisherName unresolved: signing disabled, an explicit `publisherName: null` (no opt-out any more since v27), or no
28
+ * certificate to derive it from.
29
+ */
30
+ export declare function missingUpdatePublisherNameError(options: WindowsConfiguration): InvalidConfigurationError;
31
+ //# sourceMappingURL=publisherName.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"publisherName.d.ts","sourceRoot":"","sources":["../../../src/codeSign/win/publisherName.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,yBAAyB,EAAE,MAAM,cAAc,CAAA;AAExD,OAAO,EAAgE,oBAAoB,EAAE,MAAM,6BAA6B,CAAA;AAGhI,eAAO,MAAM,0BAA0B,mHAAmH,CAAA;AAE1J,eAAO,MAAM,+BAA+B,gHAAgH,CAAA;AAE5J,iGAAiG;AACjG,eAAO,MAAM,6BAA6B,QAE0F,CAAA;AAEpI,8GAA8G;AAC9G,wBAAgB,qBAAqB,CAAC,aAAa,EAAE,MAAM,GAAG,aAAa,CAAC,MAAM,CAAC,GAAG,KAAK,CAAC,OAAO,CAAC,CAInG;AAMD;;;;;GAKG;AACH,wBAAgB,2BAA2B,CAAC,aAAa,EAAE,MAAM,GAAG,aAAa,CAAC,MAAM,CAAC,GAAG,IAAI,GAAG,SAAS,EAAE,SAAS,SAA2B,GAAG,IAAI,CAaxJ;AAED;;;;;;GAMG;AACH,wBAAgB,mBAAmB,CAAC,UAAU,EAAE,MAAM,GAAG,MAAM,CAU9D;AAED;;;;;GAKG;AACH,wBAAgB,+BAA+B,CAAC,OAAO,EAAE,oBAAoB,GAAG,yBAAyB,CAkBxG"}
@@ -0,0 +1,78 @@
1
+ import { InvalidConfigurationError } from "builder-util";
2
+ import { isValidPublisherNameDn } from "builder-util-runtime";
3
+ import { isWindowsSigningDisabled, resolveWindowsSigningConfiguration } from "../../options/winOptions.js";
4
+ import { quoteWindowsDnValue } from "./authenticodeSignature.js";
5
+ export const PUBLISHER_NAME_DN_DOCS_URL = "https://www.electron.build/docs/migration/v27-build-changes#windows-publishername-must-be-a-distinguished-name";
6
+ export const MISSING_PUBLISHER_NAME_DOCS_URL = "https://www.electron.build/docs/migration/v27-build-changes#missing-publishername-fails-update-verification";
7
+ /** What electron-updater 7 requires of a publisher name, for the error messages of the build. */
8
+ export const PUBLISHER_NAME_DN_REQUIREMENT = 'Since electron-builder v27, each publisherName entry must be in distinguished name (DN) format, e.g. "CN=My Company, O=My Company, C=US" ' +
9
+ "(the subject of the code signing certificate, or the attributes of it to compare) — electron-updater 7 never matches a bare name";
10
+ /** The entries of a publisherName that are not a valid publisher name DN ({@link isValidPublisherNameDn}). */
11
+ export function invalidPublisherNames(publisherName) {
12
+ // typed as configured, but a hand-written JSON value may be anything: an entry that is no string is reported as invalid
13
+ const entries = Array.isArray(publisherName) ? publisherName : [publisherName];
14
+ return entries.filter(it => !isValidPublisherNameDn(it));
15
+ }
16
+ function formatPublisherNames(names) {
17
+ return names.map(it => (typeof it === "string" ? `"${it}"` : `(${typeof it})`)).join(", ");
18
+ }
19
+ /**
20
+ * Throws an {@link InvalidConfigurationError} when an explicitly configured publisherName has an entry that is not a
21
+ * distinguished name ({@link isValidPublisherNameDn}), which electron-updater 7 could never match. `null` / `undefined` (none /
22
+ * derive from the certificate) are not validated: a build that writes `app-update.yml` without a publisherName fails elsewhere
23
+ * ({@link missingUpdatePublisherNameError}).
24
+ */
25
+ export function validatePublisherNameFormat(publisherName, configKey = "win.sign.publisherName") {
26
+ if (publisherName == null) {
27
+ return;
28
+ }
29
+ const invalid = invalidPublisherNames(publisherName);
30
+ if (invalid.length === 0) {
31
+ return;
32
+ }
33
+ throw new InvalidConfigurationError(`${configKey} ${formatPublisherNames(invalid)} is not a distinguished name. ${PUBLISHER_NAME_DN_REQUIREMENT}. ` +
34
+ `Set ${configKey} to the subject of the certificate that signs your app (on Windows, (Get-AuthenticodeSignature <signed .exe>).SignerCertificate.Subject prints it), ` +
35
+ `or set win.verifyUpdateCodeSignature: false to opt out of update signature verification. See ${PUBLISHER_NAME_DN_DOCS_URL}`);
36
+ }
37
+ /**
38
+ * The publisher name written to `app-update.yml` when none is configured: `CN=<common name>` of the signing certificate,
39
+ * with the value quoted the way Windows quotes it in the subject it reports (`X509Certificate2.Subject`, which electron-updater
40
+ * matches against), so a common name containing e.g. `,`, `+` or `"` matches the signer's CN. Only the CN is pinned, so a
41
+ * renewed certificate whose other subject attributes change still matches; a stricter pin is an explicit publisherName.
42
+ * Throws an {@link InvalidConfigurationError} when the certificate has no common name (empty).
43
+ */
44
+ export function derivePublisherName(commonName) {
45
+ const publisherName = `CN=${quoteWindowsDnValue(commonName)}`;
46
+ if (commonName.length === 0 || !isValidPublisherNameDn(publisherName)) {
47
+ throw new InvalidConfigurationError(`Cannot derive publisherName from the code signing certificate: its Common Name (${JSON.stringify(commonName)}) cannot form a distinguished name. ` +
48
+ `Set win.sign.publisherName explicitly to the subject of the certificate that signs your updates (or the attributes of it to compare), ` +
49
+ `or set win.verifyUpdateCodeSignature: false to opt out of update signature verification. See ${PUBLISHER_NAME_DN_DOCS_URL}`);
50
+ }
51
+ return publisherName;
52
+ }
53
+ /**
54
+ * The error for a Windows build that would write `app-update.yml` without a publisherName while update signature verification is
55
+ * enabled (`win.verifyUpdateCodeSignature` is not `false`): electron-updater 7 rejects every update of such an app. The reason names
56
+ * what left the publisherName unresolved: signing disabled, an explicit `publisherName: null` (no opt-out any more since v27), or no
57
+ * certificate to derive it from.
58
+ */
59
+ export function missingUpdatePublisherNameError(options) {
60
+ const signing = resolveWindowsSigningConfiguration(options);
61
+ let reason;
62
+ if (isWindowsSigningDisabled(options)) {
63
+ reason = `win.sign is ${options.sign === false ? "false" : "null"} (signing disabled), so no publisherName is derived from a code signing certificate`;
64
+ }
65
+ else if (signing?.publisherName === null) {
66
+ reason = "win.sign.publisherName is null, which no longer opts out of update signature verification since electron-builder v27";
67
+ }
68
+ else {
69
+ reason =
70
+ "no code signing certificate is configured (win.sign.certificateFile, WIN_CSC_LINK / CSC_LINK, win.sign.certificateSubjectName or win.sign.certificateSha1) to derive publisherName from";
71
+ }
72
+ return new InvalidConfigurationError(`Cannot write app-update.yml without publisherName: ${reason}. ` +
73
+ "Since electron-builder v27, electron-updater 7 rejects every update of an app whose app-update.yml has no publisherName (it used to skip the signature verification). " +
74
+ "Sign the build with a code signing certificate (electron-builder then writes CN=<common name> of it), " +
75
+ 'set win.sign.publisherName to the distinguished name of the certificate that signs your installer (e.g. win.sign: { type: "signtool", publisherName: ["CN=My Company, O=My Company, C=US"] } when you sign outside electron-builder), ' +
76
+ `or set win.verifyUpdateCodeSignature: false to opt out of update signature verification explicitly. See ${MISSING_PUBLISHER_NAME_DOCS_URL}`);
77
+ }
78
+ //# sourceMappingURL=publisherName.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"publisherName.js","sourceRoot":"","sources":["../../../src/codeSign/win/publisherName.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,yBAAyB,EAAE,MAAM,cAAc,CAAA;AACxD,OAAO,EAAE,sBAAsB,EAAE,MAAM,sBAAsB,CAAA;AAC7D,OAAO,EAAE,wBAAwB,EAAE,kCAAkC,EAAwB,MAAM,6BAA6B,CAAA;AAChI,OAAO,EAAE,mBAAmB,EAAE,MAAM,4BAA4B,CAAA;AAEhE,MAAM,CAAC,MAAM,0BAA0B,GAAG,gHAAgH,CAAA;AAE1J,MAAM,CAAC,MAAM,+BAA+B,GAAG,6GAA6G,CAAA;AAE5J,iGAAiG;AACjG,MAAM,CAAC,MAAM,6BAA6B,GACxC,2IAA2I;IAC3I,kIAAkI,CAAA;AAEpI,8GAA8G;AAC9G,MAAM,UAAU,qBAAqB,CAAC,aAA6C;IACjF,wHAAwH;IACxH,MAAM,OAAO,GAA2B,KAAK,CAAC,OAAO,CAAC,aAAa,CAAC,CAAC,CAAC,CAAC,aAAa,CAAC,CAAC,CAAC,CAAC,aAAa,CAAC,CAAA;IACtG,OAAO,OAAO,CAAC,MAAM,CAAC,EAAE,CAAC,EAAE,CAAC,CAAC,sBAAsB,CAAC,EAAE,CAAC,CAAC,CAAA;AAC1D,CAAC;AAED,SAAS,oBAAoB,CAAC,KAA6B;IACzD,OAAO,KAAK,CAAC,GAAG,CAAC,EAAE,CAAC,EAAE,CAAC,CAAC,OAAO,EAAE,KAAK,QAAQ,CAAC,CAAC,CAAC,IAAI,EAAE,GAAG,CAAC,CAAC,CAAC,IAAI,OAAO,EAAE,GAAG,CAAC,CAAC,CAAC,IAAI,CAAC,IAAI,CAAC,CAAA;AAC5F,CAAC;AAED;;;;;GAKG;AACH,MAA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G,sHAAsH,CAAA;IACjI,CAAC;SAAM,CAAC;QACN,MAAM;YACJ,yLAAyL,CAAA;IAC7L,CAAC;IACD,OAAO,IAAI,yBAAyB,CAClC,sDAAsD,MAAM,IAAI;QAC9D,wKAAwK;QACxK,wGAAwG;QACxG,wOAAwO;QACxO,2GAA2G,+BAA+B,EAAE,CAC/I,CAAA;AACH,CAAC","sourcesContent":["import { InvalidConfigurationError } from \"builder-util\"\nimport { isValidPublisherNameDn } from \"builder-util-runtime\"\nimport { isWindowsSigningDisabled, resolveWindowsSigningConfiguration, WindowsConfiguration } from \"../../options/winOptions.js\"\nimport { quoteWindowsDnValue } from \"./authenticodeSignature.js\"\n\nexport const PUBLISHER_NAME_DN_DOCS_URL = \"https://www.electron.build/docs/migration/v27-build-changes#windows-publishername-must-be-a-distinguished-name\"\n\nexport const MISSING_PUBLISHER_NAME_DOCS_URL = \"https://www.electron.build/docs/migration/v27-build-changes#missing-publishername-fails-update-verification\"\n\n/** What electron-updater 7 requires of a publisher name, for the error messages of the build. */\nexport const PUBLISHER_NAME_DN_REQUIREMENT =\n 'Since electron-builder v27, each publisherName entry must be in distinguished name (DN) format, e.g. \"CN=My Company, O=My Company, C=US\" ' +\n \"(the subject of the code signing certificate, or the attributes of it to compare) — electron-updater 7 never matches a bare name\"\n\n/** The entries of a publisherName that are not a valid publisher name DN ({@link isValidPublisherNameDn}). */\nexport function invalidPublisherNames(publisherName: string | ReadonlyArray<string>): Array<unknown> {\n // typed as configured, but a hand-written JSON value may be anything: an entry that is no string is reported as invalid\n const entries: ReadonlyArray<unknown> = Array.isArray(publisherName) ? publisherName : [publisherName]\n return entries.filter(it => !isValidPublisherNameDn(it))\n}\n\nfunction formatPublisherNames(names: ReadonlyArray<unknown>): string {\n return names.map(it => (typeof it === \"string\" ? `\"${it}\"` : `(${typeof it})`)).join(\", \")\n}\n\n/**\n * Throws an {@link InvalidConfigurationError} when an explicitly configured publisherName has an entry that is not a\n * distinguished name ({@link isValidPublisherNameDn}), which electron-updater 7 could never match. `null` / `undefined` (none /\n * derive from the certificate) are not validated: a build that writes `app-update.yml` without a publisherName fails elsewhere\n * ({@link missingUpdatePublisherNameError}).\n */\nexport function validatePublisherNameFormat(publisherName: string | ReadonlyArray<string> | null | undefined, configKey = \"win.sign.publisherName\"): void {\n if (publisherName == null) {\n return\n }\n const invalid = invalidPublisherNames(publisherName)\n if (invalid.length === 0) {\n return\n }\n throw new InvalidConfigurationError(\n `${configKey} ${formatPublisherNames(invalid)} is not a distinguished name. ${PUBLISHER_NAME_DN_REQUIREMENT}. ` +\n `Set ${configKey} to the subject of the certificate that signs your app (on Windows, (Get-AuthenticodeSignature <signed .exe>).SignerCertificate.Subject prints it), ` +\n `or set win.verifyUpdateCodeSignature: false to opt out of update signature verification. See ${PUBLISHER_NAME_DN_DOCS_URL}`\n )\n}\n\n/**\n * The publisher name written to `app-update.yml` when none is configured: `CN=<common name>` of the signing certificate,\n * with the value quoted the way Windows quotes it in the subject it reports (`X509Certificate2.Subject`, which electron-updater\n * matches against), so a common name containing e.g. `,`, `+` or `\"` matches the signer's CN. Only the CN is pinned, so a\n * renewed certificate whose other subject attributes change still matches; a stricter pin is an explicit publisherName.\n * Throws an {@link InvalidConfigurationError} when the certificate has no common name (empty).\n */\nexport function derivePublisherName(commonName: string): string {\n const publisherName = `CN=${quoteWindowsDnValue(commonName)}`\n if (commonName.length === 0 || !isValidPublisherNameDn(publisherName)) {\n throw new InvalidConfigurationError(\n `Cannot derive publisherName from the code signing certificate: its Common Name (${JSON.stringify(commonName)}) cannot form a distinguished name. ` +\n `Set win.sign.publisherName explicitly to the subject of the certificate that signs your updates (or the attributes of it to compare), ` +\n `or set win.verifyUpdateCodeSignature: false to opt out of update signature verification. See ${PUBLISHER_NAME_DN_DOCS_URL}`\n )\n }\n return publisherName\n}\n\n/**\n * The error for a Windows build that would write `app-update.yml` without a publisherName while update signature verification is\n * enabled (`win.verifyUpdateCodeSignature` is not `false`): electron-updater 7 rejects every update of such an app. The reason names\n * what left the publisherName unresolved: signing disabled, an explicit `publisherName: null` (no opt-out any more since v27), or no\n * certificate to derive it from.\n */\nexport function missingUpdatePublisherNameError(options: WindowsConfiguration): InvalidConfigurationError {\n const signing = resolveWindowsSigningConfiguration(options)\n let reason: string\n if (isWindowsSigningDisabled(options)) {\n reason = `win.sign is ${options.sign === false ? \"false\" : \"null\"} (signing disabled), so no publisherName is derived from a code signing certificate`\n } else if (signing?.publisherName === null) {\n reason = \"win.sign.publisherName is null, which no longer opts out of update signature verification since electron-builder v27\"\n } else {\n reason =\n \"no code signing certificate is configured (win.sign.certificateFile, WIN_CSC_LINK / CSC_LINK, win.sign.certificateSubjectName or win.sign.certificateSha1) to derive publisherName from\"\n }\n return new InvalidConfigurationError(\n `Cannot write app-update.yml without publisherName: ${reason}. ` +\n \"Since electron-builder v27, electron-updater 7 rejects every update of an app whose app-update.yml has no publisherName (it used to skip the signature verification). \" +\n \"Sign the build with a code signing certificate (electron-builder then writes CN=<common name> of it), \" +\n 'set win.sign.publisherName to the distinguished name of the certificate that signs your installer (e.g. win.sign: { type: \"signtool\", publisherName: [\"CN=My Company, O=My Company, C=US\"] } when you sign outside electron-builder), ' +\n `or set win.verifyUpdateCodeSignature: false to opt out of update signature verification explicitly. See ${MISSING_PUBLISHER_NAME_DOCS_URL}`\n )\n}\n"]}
@@ -29,6 +29,11 @@ export interface CustomWindowsSignTaskConfiguration extends WindowsSignTaskConfi
29
29
  export interface CertificateInfo {
30
30
  readonly commonName: string;
31
31
  readonly bloodyMicrosoftSubjectDn: string;
32
+ /**
33
+ * The subject in the format Windows reports it (`X509Certificate2.Subject`), which electron-updater matches
34
+ * publisherName against. Unset when `bloodyMicrosoftSubjectDn` already is in that format (certificate store).
35
+ */
36
+ readonly windowsSubjectDn?: string;
32
37
  }
33
38
  export interface CertificateFromStoreInfo {
34
39
  thumbprint: string;
@@ -38,13 +43,14 @@ export interface CertificateFromStoreInfo {
38
43
  }
39
44
  /** Extracts the non-Azure signing config from WindowsConfiguration, or null for Azure/unset/disabled. */
40
45
  export declare function getSigntoolFamilyConfig(config: WindowsConfiguration): WindowsSigntoolFamilyConfig | null;
46
+ /** The certificate subject in the format Windows reports it, which electron-updater matches publisherName against. */
47
+ export declare function certificateWindowsSubjectDn(certInfo: CertificateInfo): string;
41
48
  /**
42
- * Matches configured publisher names against a certificate subject using the same semantics as
43
- * electron-updater's update signature verifier (windowsExecutableCodeSignatureVerifier): a name that
44
- * parses as a Distinguished Name (DN) must match every RDN it specifies against the certificate
45
- * subject (extra subject RDNs are ignored); otherwise it is compared strictly against the
46
- * certificate's Common Name (CN). Passes when ANY configured name matches — multiple names are
47
- * supported for certificate rotation.
49
+ * Matches configured publisher names against a certificate subject with the matcher electron-updater's update
50
+ * signature verifier uses ({@link matchPublisherName}): a name must be a Distinguished Name (DN), and every RDN it
51
+ * specifies must equal the certificate subject's (extra subject RDNs are ignored). Passes when ANY
52
+ * configured name matches — multiple names are supported for certificate rotation. The subject is taken in the format
53
+ * Windows reports it (as the updater sees it).
48
54
  */
49
55
  export declare function publisherNameMatchesCertificate(publisherNames: Array<string>, certInfo: CertificateInfo): boolean;
50
56
  export declare abstract class SigntoolBaseSignManager implements SignManager {
@@ -55,8 +61,9 @@ export declare abstract class SigntoolBaseSignManager implements SignManager {
55
61
  readonly lazyCertInfo: MemoLazy<MemoLazy<WindowsConfiguration, FileCodeSigningInfo | CertificateFromStoreInfo | null>, CertificateInfo | null>;
56
62
  private readonly explicitPublisherNameValidation;
57
63
  /**
58
- * When `publisherName` is explicitly configured and the subject of the local code signing
59
- * certificate is known, fail the build if none of the configured names match the certificate.
64
+ * When `publisherName` is explicitly configured, fail the build if an entry is not a distinguished name
65
+ * (electron-updater 7 never matches one), whatever the signing route. Then, when the subject of the local code
66
+ * signing certificate is known, fail the build if none of the configured names match the certificate.
60
67
  * This catches signing with the wrong certificate at build time — otherwise the mismatch only
61
68
  * surfaces at update time, when electron-updater rejects every update signed with that
62
69
  * certificate.
@@ -64,7 +71,7 @@ export declare abstract class SigntoolBaseSignManager implements SignManager {
64
71
  * The check is intentionally skipped whenever the actual signing certificate's subject is not
65
72
  * genuinely known: custom `sign` hooks, PKCS#11 without an extractable certificate file,
66
73
  * x509 certificate files without a CN, or any error while reading certificate info.
67
- * An explicit `publisherName: null` remains a pure opt-out (nothing to validate).
74
+ * An explicit `publisherName: null` has nothing to validate (a build that writes `app-update.yml` with it fails in PublishManager).
68
75
  */
69
76
  protected validateExplicitPublisherName(): Promise<void>;
70
77
  readonly cscInfo: MemoLazy<WindowsConfiguration, FileCodeSigningInfo | CertificateFromStoreInfo | null>;
@@ -1 +1 @@
1
- {"version":3,"file":"signtoolBaseSignManager.d.ts","sourceRoot":"","sources":["../../../src/codeSign/win/signtoolBaseSignManager.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,QAAQ,EAAW,MAAM,sBAAsB,CAAA;AAExD,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,EAAE,QAAQ,EAAE,MAAM,2BAA2B,CAAA;AAIpD,OAAO,EAAE,SAAS,EAAE,MAAM,gBAAgB,CAAA;AAC1C,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,sBAAsB,CAAA;AAEvD,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,kBAAkB,CAAA;AACnD,OAAO,EAAE,kBAAkB,EAAE,MAAM,sBAAsB,CAAA;AACzD,OAAO,EAAE,cAAc,EAAE,MAAM,kBAAkB,CAAA;AAGjD,MAAM,MAAM,iBAAiB,GAAG,CAAC,aAAa,EAAE,kCAAkC,EAAE,QAAQ,CAAC,EAAE,WAAW,KAAK,OAAO,CAAC,GAAG,CAAC,CAAA;AAE3H,MAAM,WAAW,sBAAuB,SAAQ,kBAAkB;IAChE,QAAQ,CAAC,IAAI,EAAE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AS,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"}
@@ -1,5 +1,5 @@
1
1
  import { asArray, InvalidConfigurationError, log, retry } from "builder-util";
2
- import { MemoLazy, parseDn } from "builder-util-runtime";
2
+ import { matchPublisherName, MemoLazy, parseDn, POWERSHELL_ASCII_ESCAPE_FUNCTION } from "builder-util-runtime";
3
3
  import _fsExtra from "fs-extra";
4
4
  import { Lazy } from "lazy-val";
5
5
  import * as path from "path";
@@ -12,6 +12,9 @@ import { withSigntoolLock } from "../../util/toolsetLock.js";
12
12
  import { readCertInfo, readCertInfoFromX509 } from "../certInfo.js";
13
13
  import { VmManager } from "../../vm/vm.js";
14
14
  import { importCertificate } from "../codesign.js";
15
+ import { derivePublisherName, PUBLISHER_NAME_DN_DOCS_URL, validatePublisherNameFormat } from "./publisherName.js";
16
+ import { BUILD_CHANGES_URL } from "../../util/config/legacyOptions.js";
17
+ const PUBLISHER_NAME_DOCS = `${BUILD_CHANGES_URL}#windows-publishername-is-validated-against-the-signing-certificate`;
15
18
  const { rename } = _fsExtra;
16
19
  /** Extracts the non-Azure signing config from WindowsConfiguration, or null for Azure/unset/disabled. */
17
20
  export function getSigntoolFamilyConfig(config) {
@@ -21,29 +24,27 @@ export function getSigntoolFamilyConfig(config) {
21
24
  }
22
25
  return s;
23
26
  }
27
+ /** The certificate subject in the format Windows reports it, which electron-updater matches publisherName against. */
28
+ export function certificateWindowsSubjectDn(certInfo) {
29
+ return certInfo.windowsSubjectDn ?? certInfo.bloodyMicrosoftSubjectDn;
30
+ }
24
31
  /**
25
- * Matches configured publisher names against a certificate subject using the same semantics as
26
- * electron-updater's update signature verifier (windowsExecutableCodeSignatureVerifier): a name that
27
- * parses as a Distinguished Name (DN) must match every RDN it specifies against the certificate
28
- * subject (extra subject RDNs are ignored); otherwise it is compared strictly against the
29
- * certificate's Common Name (CN). Passes when ANY configured name matches — multiple names are
30
- * supported for certificate rotation.
32
+ * Matches configured publisher names against a certificate subject with the matcher electron-updater's update
33
+ * signature verifier uses ({@link matchPublisherName}): a name must be a Distinguished Name (DN), and every RDN it
34
+ * specifies must equal the certificate subject's (extra subject RDNs are ignored). Passes when ANY
35
+ * configured name matches — multiple names are supported for certificate rotation. The subject is taken in the format
36
+ * Windows reports it (as the updater sees it).
31
37
  */
32
38
  export function publisherNameMatchesCertificate(publisherNames, certInfo) {
33
- const subject = parseDn(certInfo.bloodyMicrosoftSubjectDn);
34
- return publisherNames.some(name => {
35
- const dn = parseDn(name);
36
- if (dn.size) {
37
- return Array.from(dn.keys()).every(key => dn.get(key) === subject.get(key));
38
- }
39
- return name === certInfo.commonName;
40
- });
39
+ // matchPublisherName takes the parsed Get-AuthenticodeSignature output, as electron-updater passes it
40
+ return matchPublisherName({ SignerCertificate: { Subject: certificateWindowsSubjectDn(certInfo) } }, publisherNames);
41
41
  }
42
42
  export class SigntoolBaseSignManager {
43
43
  constructor(packager) {
44
44
  this.packager = packager;
45
45
  this.computedPublisherName = new Lazy(async () => {
46
- // `win.sign: false` / `null` signs nothing, so no publisherName is derived or written to app-update.yml.
46
+ // `win.sign: false` / `null` signs nothing, so no publisherName is derived: a build that writes app-update.yml then needs
47
+ // win.verifyUpdateCodeSignature: false (or a win.sign object with publisherName), see missingUpdatePublisherNameError.
47
48
  if (isWindowsSigningDisabled(this.platformSpecificBuildOptions)) {
48
49
  return null;
49
50
  }
@@ -61,20 +62,24 @@ export class SigntoolBaseSignManager {
61
62
  if (signing?.sign != null) {
62
63
  throw new InvalidConfigurationError("A custom Windows signing hook (`win.sign.sign`) is configured without `win.sign.publisherName`. " +
63
64
  "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. " +
64
- 'Set `win.sign.publisherName` to the subject of the certificate that your hook signs with (e.g. "CN=My Company, O=My Company, C=US"), ' +
65
- "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.");
65
+ '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"), ' +
66
+ "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. " +
67
+ `See ${PUBLISHER_NAME_DOCS}`);
66
68
  }
67
69
  const certInfo = await this.lazyCertInfo.value;
68
70
  if (certInfo?.commonName) {
69
- return [certInfo.commonName];
71
+ // `CN=<common name>`, quoted as Windows reports the signer subject (which electron-updater 7 matches against): pinning only the CN
72
+ // keeps updates working across a certificate renewal that changes other subject attributes. A stricter pin is an explicit publisherName.
73
+ return [derivePublisherName(certInfo.commonName)];
70
74
  }
71
- // Signed with a certificate without a CN: electron-updater verifies downloaded updates against the publisherName in app-update.yml, so
72
- // the build needs one.
75
+ // Signed with a certificate without a CN (or whose subject cannot be read): electron-updater verifies downloaded updates against the
76
+ // publisherName in app-update.yml, so the build needs one.
73
77
  if ((await this.cscInfo.value) != null) {
74
78
  throw new InvalidConfigurationError("Windows code signing is configured, but the publisher name cannot be determined at build time (the signing certificate has no Common Name). " +
75
79
  "electron-updater verifies the signature of downloaded updates against the publisherName in app-update.yml. " +
76
- 'Set `win.sign.publisherName` to the subject of the certificate that signs your app (e.g. "CN=My Company, O=My Company, C=US"), ' +
77
- "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.");
80
+ '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"), ' +
81
+ "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. " +
82
+ `See ${PUBLISHER_NAME_DN_DOCS_URL}`);
78
83
  }
79
84
  return null;
80
85
  });
@@ -88,6 +93,7 @@ export class SigntoolBaseSignManager {
88
93
  return {
89
94
  // empty for a subject without a CN, like readCertInfo, so computedPublisherName requires an explicit publisherName
90
95
  commonName: parseDn(bloodyMicrosoftSubjectDn).get("CN") ?? "",
96
+ // read from the Windows certificate store, so already in the format Windows reports (windowsSubjectDn falls back to it)
91
97
  bloodyMicrosoftSubjectDn,
92
98
  };
93
99
  }
@@ -166,8 +172,9 @@ export class SigntoolBaseSignManager {
166
172
  this.platformSpecificBuildOptions = packager.platformOptions;
167
173
  }
168
174
  /**
169
- * When `publisherName` is explicitly configured and the subject of the local code signing
170
- * certificate is known, fail the build if none of the configured names match the certificate.
175
+ * When `publisherName` is explicitly configured, fail the build if an entry is not a distinguished name
176
+ * (electron-updater 7 never matches one), whatever the signing route. Then, when the subject of the local code
177
+ * signing certificate is known, fail the build if none of the configured names match the certificate.
171
178
  * This catches signing with the wrong certificate at build time — otherwise the mismatch only
172
179
  * surfaces at update time, when electron-updater rejects every update signed with that
173
180
  * certificate.
@@ -175,15 +182,16 @@ export class SigntoolBaseSignManager {
175
182
  * The check is intentionally skipped whenever the actual signing certificate's subject is not
176
183
  * genuinely known: custom `sign` hooks, PKCS#11 without an extractable certificate file,
177
184
  * x509 certificate files without a CN, or any error while reading certificate info.
178
- * An explicit `publisherName: null` remains a pure opt-out (nothing to validate).
185
+ * An explicit `publisherName: null` has nothing to validate (a build that writes `app-update.yml` with it fails in PublishManager).
179
186
  */
180
187
  async validateExplicitPublisherName() {
181
188
  const signing = getSigntoolFamilyConfig(this.platformSpecificBuildOptions);
182
189
  const publisherName = signing?.publisherName;
183
190
  if (publisherName == null) {
184
- // not configured (auto-derive) or explicit `null` opt-out — nothing to validate
191
+ // not configured (auto-derive) or explicit `null` (no opt-out any more: rejected where app-update.yml is written) — nothing to validate
185
192
  return;
186
193
  }
194
+ validatePublisherNameFormat(publisherName);
187
195
  if (signing?.sign != null) {
188
196
  // custom sign hook: electron-builder does not know which certificate the hook actually signs with
189
197
  return;
@@ -208,8 +216,8 @@ export class SigntoolBaseSignManager {
208
216
  throw new InvalidConfigurationError(`The configured publisherName does not match the subject of the code signing certificate. ` +
209
217
  `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` +
210
218
  ` Configured publisherName: ${publisherNames.join(" | ")}\n` +
211
- ` Certificate subject: ${certInfo.bloodyMicrosoftSubjectDn}\n` +
212
- `Fix win.sign.publisherName (or sign with the intended certificate). To opt out of update signature verification entirely, set publisherName to null.`);
219
+ ` Certificate subject: ${certificateWindowsSubjectDn(certInfo)}\n` +
220
+ `Fix win.sign.publisherName (or sign with the intended certificate). To opt out of update signature verification entirely, set win.verifyUpdateCodeSignature: false.`);
213
221
  }
214
222
  }
215
223
  initialize() {
@@ -224,9 +232,11 @@ export class SigntoolBaseSignManager {
224
232
  // When a signing cert is available, the cert's subject MUST be used so the APPX package
225
233
  // Publisher attribute matches the certificate — any mismatch causes SignerSign to fail with
226
234
  // ERROR_BAD_FORMAT. Only honour a user-supplied publisherName if it was explicitly configured
227
- // (non-null); otherwise derive from the certificate.
235
+ // (non-null); otherwise derive from the certificate. The subject is written in the format Windows reports it
236
+ // (`, `-separated, Windows attribute names such as S): MakeAppx rejects a multi-RDN Publisher separated by a bare `,`
237
+ // or using the OpenSSL name ST.
228
238
  const certInfo = await this.lazyCertInfo.value;
229
- const publisher = publisherName ?? certInfo?.bloodyMicrosoftSubjectDn ?? null;
239
+ const publisher = publisherName ?? (certInfo == null ? null : certificateWindowsSubjectDn(certInfo));
230
240
  if (publisher == null) {
231
241
  throw new Error("Internal error: cannot compute subject using certificate info");
232
242
  }
@@ -263,14 +273,14 @@ export class SigntoolBaseSignManager {
263
273
  };
264
274
  }
265
275
  log.info(logInfo, "signing");
266
- // validate an explicitly configured publisherName against the signing certificate before the
267
- // first file is signed, so a wrong-certificate build fails even when no publish config exists
268
- await this.explicitPublisherNameValidation.value;
269
276
  }
270
277
  else if (this.handleNullCscInfo(customSign)) {
271
278
  // the canonical "signing skipped" message is logged once in signWindows, which receives this reason
272
279
  return "skipped:no-certificate";
273
280
  }
281
+ // validate an explicitly configured publisherName (its format on every signing route, and against the signing certificate when
282
+ // known) before the first file is signed, so a wrong-certificate build fails even when no publish config exists
283
+ await this.explicitPublisherNameValidation.value;
274
284
  const executor = customSign || ((config, packager) => this.doSign(config, packager));
275
285
  let isNest = false;
276
286
  for (const hash of hashes) {
@@ -364,11 +374,12 @@ export class SigntoolBaseSignManager {
364
374
  const certificateSubjectName = signing?.certificateSubjectName;
365
375
  const certificateSha1 = signing?.certificateSha1?.toUpperCase();
366
376
  const ps = await vm.powershellCommand.value;
377
+ // the non-ASCII characters of a subject are escaped, so they read back losslessly whatever the console code page
367
378
  const rawResult = await vm.exec(ps, [
368
379
  "-NoProfile",
369
380
  "-NonInteractive",
370
381
  "-Command",
371
- "Get-ChildItem -Recurse Cert: -CodeSigningCert | Select-Object -Property Subject,PSParentPath,Thumbprint | ConvertTo-Json -Compress",
382
+ `${POWERSHELL_ASCII_ESCAPE_FUNCTION}; $json = Get-ChildItem -Recurse Cert: -CodeSigningCert | Select-Object -Property Subject,PSParentPath,Thumbprint | ConvertTo-Json -Compress; if ($json) { ConvertTo-AsciiEscaped $json }`,
372
383
  ]);
373
384
  const certList = rawResult.length === 0 ? [] : asArray(JSON.parse(rawResult));
374
385
  for (const certInfo of certList) {