Skip to content

Commit

Permalink
fix(windows): fix encoding issues while verifying signatures (#5071)
Browse files Browse the repository at this point in the history
  • Loading branch information
orzFly authored Jul 9, 2020
1 parent a887d23 commit 70a0b80
Showing 1 changed file with 3 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ export function verifySignature(publisherNames: Array<string>, tempUpdateFile: s
return new Promise<string | null>(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 {
Expand All @@ -20,7 +20,7 @@ export function verifySignature(publisherNames: Array<string>, 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)) {
Expand Down Expand Up @@ -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")
}
}

0 comments on commit 70a0b80

Please sign in to comment.