From c2eb8c225c366966cd1aaad0a46a2a16b117700d Mon Sep 17 00:00:00 2001 From: develar Date: Wed, 30 Nov 2016 19:25:07 +0100 Subject: [PATCH] feat: win code sign timestamp server option Closes #951 --- docs/Multi Platform Build.md | 2 +- docs/Options.md | 1 + src/options/winOptions.ts | 5 +++++ src/packager.ts | 7 ++++--- src/winPackager.ts | 3 +-- src/windowsCodeSign.ts | 13 +++++++------ 6 files changed, 19 insertions(+), 12 deletions(-) diff --git a/docs/Multi Platform Build.md b/docs/Multi Platform Build.md index be04daa33ec..766caf8b83c 100755 --- a/docs/Multi Platform Build.md +++ b/docs/Multi Platform Build.md @@ -81,4 +81,4 @@ dist: trusty ## Windows -Use [Docker](https://github.com/electron-userland/electron-builder/wiki/Docker). +Please use [Docker](https://github.com/electron-userland/electron-builder/wiki/Docker). diff --git a/docs/Options.md b/docs/Options.md index c8e1d263059..9b62d1e9e39 100644 --- a/docs/Options.md +++ b/docs/Options.md @@ -278,6 +278,7 @@ Windows specific build options. | certificatePassword |

The password to the certificate provided in certificateFile. Please use it only if you cannot use env variable CSC_KEY_PASSWORD (WIN_CSC_KEY_PASSWORD) for some reason. Please see [Code Signing](https://github.com/electron-userland/electron-builder/wiki/Code-Signing).

| certificateSubjectName | The name of the subject of the signing certificate. Required only for EV Code Signing and works only on Windows. | rfc3161TimeStampServer | The URL of the RFC 3161 time stamp server. Defaults to `http://timestamp.comodoca.com/rfc3161`. +| timeStampServer | The URL of the time stamp server. Defaults to `http://timestamp.verisign.com/scripts/timstamp.dll`. ## `.directories` diff --git a/src/options/winOptions.ts b/src/options/winOptions.ts index b5f1f7e17e2..da1b34d1f76 100644 --- a/src/options/winOptions.ts +++ b/src/options/winOptions.ts @@ -51,6 +51,11 @@ export interface WinBuildOptions extends PlatformSpecificBuildOptions { The URL of the RFC 3161 time stamp server. Defaults to `http://timestamp.comodoca.com/rfc3161`. */ readonly rfc3161TimeStampServer?: string + + /* + The URL of the time stamp server. Defaults to `http://timestamp.verisign.com/scripts/timstamp.dll`. + */ + readonly timeStampServer?: string } /* diff --git a/src/packager.ts b/src/packager.ts index a9e4ea0b7d6..a734aa9277d 100644 --- a/src/packager.ts +++ b/src/packager.ts @@ -285,7 +285,7 @@ function checkConflictingOptions(options: any) { async function checkWineVersion(checkPromise: Promise) { function wineError(prefix: string): string { - return `${prefix}, please see https://github.com/electron-userland/electron-builder/wiki/Multi-Platform-Build#${(process.platform === "linux" ? "linux" : "os-x")}` + return `${prefix}, please see https://github.com/electron-userland/electron-builder/wiki/Multi-Platform-Build#${(process.platform === "linux" ? "linux" : "macos")}` } let wineVersion: string @@ -305,8 +305,9 @@ async function checkWineVersion(checkPromise: Promise) { wineVersion = wineVersion.substring("wine-".length) } - if (wineVersion.split(" ").length > 1) { - wineVersion = wineVersion.split(" ")[0] + const spaceIndex = wineVersion.indexOf(" ") + if (spaceIndex > 0) { + wineVersion = wineVersion.substring(0, spaceIndex) } if (wineVersion.split(".").length === 2) { diff --git a/src/winPackager.ts b/src/winPackager.ts index fd1f38d130e..2a5043cf7e4 100644 --- a/src/winPackager.ts +++ b/src/winPackager.ts @@ -134,8 +134,7 @@ export class WinPackager extends PlatformPackager { password: cscInfo.password, name: this.appInfo.productName, site: await this.appInfo.computePackageUrl(), - hash: this.platformSpecificBuildOptions.signingHashAlgorithms, - tr: this.platformSpecificBuildOptions.rfc3161TimeStampServer, + options: this.platformSpecificBuildOptions, }) } diff --git a/src/windowsCodeSign.ts b/src/windowsCodeSign.ts index b4705e7386f..8764d3ed601 100644 --- a/src/windowsCodeSign.ts +++ b/src/windowsCodeSign.ts @@ -4,10 +4,12 @@ import * as path from "path" import { release } from "os" import { getBinFromBintray } from "./util/binDownload" import isCi from "is-ci" +import { WinBuildOptions } from "./options/winOptions" const TOOLS_VERSION = "1.5.0" export function getSignVendorPath() { + //noinspection SpellCheckingInspection return getBinFromBintray("winCodeSign", TOOLS_VERSION, "5febefb4494f0f62f0f5c0cd6408f0930caf5943ccfeea2bbf90d2eeb34c571d") } @@ -20,13 +22,12 @@ export interface SignOptions { readonly name?: string | null readonly password?: string | null readonly site?: string | null - readonly hash?: Array | null - readonly tr?: string | null + readonly options: WinBuildOptions } export async function sign(options: SignOptions) { - let hashes = options.hash + let hashes = options.options.signingHashAlgorithms // msi does not support dual-signing if (options.path.endsWith(".msi")) { hashes = [hashes != null && !hashes.includes("sha1") ? "sha256" : "sha1"] @@ -47,7 +48,7 @@ export async function sign(options: SignOptions) { let nest = false //noinspection JSUnusedAssignment let outputPath = "" - for (let hash of hashes) { + for (const hash of hashes) { outputPath = isWin ? options.path : getOutputPath(options.path, hash) await spawnSign(options, options.path, outputPath, hash, nest) nest = true @@ -63,9 +64,9 @@ async function spawnSign(options: SignOptions, inputPath: string, outputPath: st const args = isWin ? ["sign"] : ["-in", inputPath, "-out", outputPath] if (process.env.ELECTRON_BUILDER_OFFLINE !== "true") { - const timestampingServiceUrl = "http://timestamp.verisign.com/scripts/timstamp.dll" + const timestampingServiceUrl = options.options.timeStampServer || "http://timestamp.verisign.com/scripts/timstamp.dll" if (isWin) { - args.push(nest || hash === "sha256" ? "/tr" : "/t", nest || hash === "sha256" ? (options.tr || "http://timestamp.comodoca.com/rfc3161") : timestampingServiceUrl) + args.push(nest || hash === "sha256" ? "/tr" : "/t", nest || hash === "sha256" ? (options.options.rfc3161TimeStampServer || "http://timestamp.comodoca.com/rfc3161") : timestampingServiceUrl) } else { args.push("-t", timestampingServiceUrl)