From 70a0b802b6225adb592f799c7cb129759d4b1c5c Mon Sep 17 00:00:00 2001 From: Yeechan Lu Date: Thu, 9 Jul 2020 16:51:48 +0800 Subject: [PATCH] fix(windows): fix encoding issues while verifying signatures (#5071) --- .../src/windowsExecutableCodeSignatureVerifier.ts | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/packages/electron-updater/src/windowsExecutableCodeSignatureVerifier.ts b/packages/electron-updater/src/windowsExecutableCodeSignatureVerifier.ts index 0aac2761eab..533687bd869 100644 --- a/packages/electron-updater/src/windowsExecutableCodeSignatureVerifier.ts +++ b/packages/electron-updater/src/windowsExecutableCodeSignatureVerifier.ts @@ -10,7 +10,7 @@ export function verifySignature(publisherNames: Array, tempUpdateFile: s return new Promise(resolve => { // https://github.com/electron-userland/electron-builder/issues/2421 // https://github.com/electron-userland/electron-builder/issues/2535 - execFile("powershell.exe", ["-NoProfile", "-NonInteractive", "-InputFormat", "None", "-Command", `Get-AuthenticodeSignature '${tempUpdateFile}' | ConvertTo-Json -Compress`], { + execFile("powershell.exe", ["-NoProfile", "-NonInteractive", "-InputFormat", "None", "-Command", `Get-AuthenticodeSignature '${tempUpdateFile}' | ConvertTo-Json -Compress | ForEach-Object { [Convert]::ToBase64String([System.Text.Encoding]::UTF8.GetBytes($_)) }`], { timeout: 20 * 1000 }, (error, stdout, stderr) => { try { @@ -20,7 +20,7 @@ export function verifySignature(publisherNames: Array, tempUpdateFile: s return } - const data = parseOut(stdout) + const data = parseOut(Buffer.from(stdout, "base64").toString("utf-8")) if (data.Status === 0) { const name = parseDn(data.SignerCertificate.Subject).get("CN")! if (publisherNames.includes(name)) { @@ -87,4 +87,4 @@ function handleError(logger: Logger, error: Error | null, stderr: string | null) function isOldWin6(): boolean { const winVersion = os.release() return winVersion.startsWith("6.") && !winVersion.startsWith("6.3") -} \ No newline at end of file +}