Skip to content

Commit c2eb8c2

Browse files
committed
feat: win code sign timestamp server option
Closes #951
1 parent da16181 commit c2eb8c2

File tree

6 files changed

+19
-12
lines changed

6 files changed

+19
-12
lines changed

docs/Multi Platform Build.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -81,4 +81,4 @@ dist: trusty
8181
8282
## Windows
8383
84-
Use [Docker](https://github.com/electron-userland/electron-builder/wiki/Docker).
84+
Please use [Docker](https://github.com/electron-userland/electron-builder/wiki/Docker).

docs/Options.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -278,6 +278,7 @@ Windows specific build options.
278278
| certificatePassword | <a name="WinBuildOptions-certificatePassword"></a><p>The password to the certificate provided in <code>certificateFile</code>. Please use it only if you cannot use env variable <code>CSC_KEY_PASSWORD</code> (<code>WIN_CSC_KEY_PASSWORD</code>) for some reason. Please see [Code Signing](https://github.com/electron-userland/electron-builder/wiki/Code-Signing).</p>
279279
| certificateSubjectName | <a name="WinBuildOptions-certificateSubjectName"></a>The name of the subject of the signing certificate. Required only for EV Code Signing and works only on Windows.
280280
| rfc3161TimeStampServer | <a name="WinBuildOptions-rfc3161TimeStampServer"></a>The URL of the RFC 3161 time stamp server. Defaults to `http://timestamp.comodoca.com/rfc3161`.
281+
| timeStampServer | <a name="WinBuildOptions-timeStampServer"></a>The URL of the time stamp server. Defaults to `http://timestamp.verisign.com/scripts/timstamp.dll`.
281282

282283
<a name="MetadataDirectories"></a>
283284
## `.directories`

src/options/winOptions.ts

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -51,6 +51,11 @@ export interface WinBuildOptions extends PlatformSpecificBuildOptions {
5151
The URL of the RFC 3161 time stamp server. Defaults to `http://timestamp.comodoca.com/rfc3161`.
5252
*/
5353
readonly rfc3161TimeStampServer?: string
54+
55+
/*
56+
The URL of the time stamp server. Defaults to `http://timestamp.verisign.com/scripts/timstamp.dll`.
57+
*/
58+
readonly timeStampServer?: string
5459
}
5560

5661
/*

src/packager.ts

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -285,7 +285,7 @@ function checkConflictingOptions(options: any) {
285285

286286
async function checkWineVersion(checkPromise: Promise<string>) {
287287
function wineError(prefix: string): string {
288-
return `${prefix}, please see https://github.com/electron-userland/electron-builder/wiki/Multi-Platform-Build#${(process.platform === "linux" ? "linux" : "os-x")}`
288+
return `${prefix}, please see https://github.com/electron-userland/electron-builder/wiki/Multi-Platform-Build#${(process.platform === "linux" ? "linux" : "macos")}`
289289
}
290290

291291
let wineVersion: string
@@ -305,8 +305,9 @@ async function checkWineVersion(checkPromise: Promise<string>) {
305305
wineVersion = wineVersion.substring("wine-".length)
306306
}
307307

308-
if (wineVersion.split(" ").length > 1) {
309-
wineVersion = wineVersion.split(" ")[0]
308+
const spaceIndex = wineVersion.indexOf(" ")
309+
if (spaceIndex > 0) {
310+
wineVersion = wineVersion.substring(0, spaceIndex)
310311
}
311312

312313
if (wineVersion.split(".").length === 2) {

src/winPackager.ts

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -134,8 +134,7 @@ export class WinPackager extends PlatformPackager<WinBuildOptions> {
134134
password: cscInfo.password,
135135
name: this.appInfo.productName,
136136
site: await this.appInfo.computePackageUrl(),
137-
hash: this.platformSpecificBuildOptions.signingHashAlgorithms,
138-
tr: this.platformSpecificBuildOptions.rfc3161TimeStampServer,
137+
options: this.platformSpecificBuildOptions,
139138
})
140139
}
141140

src/windowsCodeSign.ts

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -4,10 +4,12 @@ import * as path from "path"
44
import { release } from "os"
55
import { getBinFromBintray } from "./util/binDownload"
66
import isCi from "is-ci"
7+
import { WinBuildOptions } from "./options/winOptions"
78

89
const TOOLS_VERSION = "1.5.0"
910

1011
export function getSignVendorPath() {
12+
//noinspection SpellCheckingInspection
1113
return getBinFromBintray("winCodeSign", TOOLS_VERSION, "5febefb4494f0f62f0f5c0cd6408f0930caf5943ccfeea2bbf90d2eeb34c571d")
1214
}
1315

@@ -20,13 +22,12 @@ export interface SignOptions {
2022
readonly name?: string | null
2123
readonly password?: string | null
2224
readonly site?: string | null
23-
readonly hash?: Array<string> | null
2425

25-
readonly tr?: string | null
26+
readonly options: WinBuildOptions
2627
}
2728

2829
export async function sign(options: SignOptions) {
29-
let hashes = options.hash
30+
let hashes = options.options.signingHashAlgorithms
3031
// msi does not support dual-signing
3132
if (options.path.endsWith(".msi")) {
3233
hashes = [hashes != null && !hashes.includes("sha1") ? "sha256" : "sha1"]
@@ -47,7 +48,7 @@ export async function sign(options: SignOptions) {
4748
let nest = false
4849
//noinspection JSUnusedAssignment
4950
let outputPath = ""
50-
for (let hash of hashes) {
51+
for (const hash of hashes) {
5152
outputPath = isWin ? options.path : getOutputPath(options.path, hash)
5253
await spawnSign(options, options.path, outputPath, hash, nest)
5354
nest = true
@@ -63,9 +64,9 @@ async function spawnSign(options: SignOptions, inputPath: string, outputPath: st
6364
const args = isWin ? ["sign"] : ["-in", inputPath, "-out", outputPath]
6465

6566
if (process.env.ELECTRON_BUILDER_OFFLINE !== "true") {
66-
const timestampingServiceUrl = "http://timestamp.verisign.com/scripts/timstamp.dll"
67+
const timestampingServiceUrl = options.options.timeStampServer || "http://timestamp.verisign.com/scripts/timstamp.dll"
6768
if (isWin) {
68-
args.push(nest || hash === "sha256" ? "/tr" : "/t", nest || hash === "sha256" ? (options.tr || "http://timestamp.comodoca.com/rfc3161") : timestampingServiceUrl)
69+
args.push(nest || hash === "sha256" ? "/tr" : "/t", nest || hash === "sha256" ? (options.options.rfc3161TimeStampServer || "http://timestamp.comodoca.com/rfc3161") : timestampingServiceUrl)
6970
}
7071
else {
7172
args.push("-t", timestampingServiceUrl)

0 commit comments

Comments
 (0)