Skip to content

Commit 9edadb5

Browse files
committed
fix: App rejected when Mac Developer certificate is in keychain
Closes #890
1 parent 6ce683f commit 9edadb5

File tree

9 files changed

+21
-48
lines changed

9 files changed

+21
-48
lines changed

package.json

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -67,9 +67,9 @@
6767
"chromium-pickle-js": "^0.2.0",
6868
"cli-cursor": "^1.0.2",
6969
"cuint": "^0.2.2",
70-
"debug": "^2.2.0",
70+
"debug": "^2.3.2",
7171
"electron-download": "2.1.2",
72-
"electron-osx-sign-tf": "~1.1.0",
72+
"electron-macos-sign": "~1.2.3",
7373
"fs-extra-p": "^2.0.6",
7474
"hosted-git-info": "^2.1.5",
7575
"ini": "^1.3.4",

src/codeSign.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ import BluebirdPromise from "bluebird-lst-c"
77
import { randomBytes } from "crypto"
88
import { TmpDir } from "./util/tmp"
99

10-
const appleCertificatePrefixes = ["Developer ID Application:", "Developer ID Installer:", "3rd Party Mac Developer Application:", "3rd Party Mac Developer Installer:"]
10+
export const appleCertificatePrefixes = ["Developer ID Application:", "Developer ID Installer:", "3rd Party Mac Developer Application:", "3rd Party Mac Developer Installer:"]
1111

1212
export type CertType = "Developer ID Application" | "Developer ID Installer" | "3rd Party Mac Developer Application" | "3rd Party Mac Developer Installer" | "Mac Developer"
1313

src/macPackager.ts

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -4,9 +4,9 @@ import { MasBuildOptions, MacOptions } from "./options/macOptions"
44
import * as path from "path"
55
import BluebirdPromise from "bluebird-lst-c"
66
import { log, warn, task } from "./util/log"
7-
import { createKeychain, CodeSigningInfo, findIdentity } from "./codeSign"
7+
import { createKeychain, CodeSigningInfo, findIdentity, appleCertificatePrefixes } from "./codeSign"
88
import { deepAssign } from "./util/deepAssign"
9-
import { signAsync, SignOptions } from "electron-osx-sign-tf"
9+
import { signAsync, SignOptions } from "electron-macos-sign"
1010
import { DmgTarget } from "./targets/dmg"
1111
import { createCommonTarget, DEFAULT_TARGET, DIR_TARGET } from "./targets/targetFactory"
1212
import { AppInfo } from "./appInfo"
@@ -126,11 +126,12 @@ export default class MacPackager extends PlatformPackager<MacOptions> {
126126

127127
const appPath = path.join(appOutDir, `${this.appInfo.productFilename}.app`)
128128
const signOptions: any = {
129-
identity: name,
129+
identity: name!,
130130
platform: isMas ? "mas" : "darwin",
131131
version: this.info.electronVersion,
132132
app: appPath,
133133
keychain: keychainName || undefined,
134+
"gatekeeper-assess": appleCertificatePrefixes.find(it => name!.startsWith(it)) != null
134135
}
135136

136137
const resourceList = await this.resourceList

src/yarn.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,7 @@ export function installDependencies(appDir: string, electronVersion: string, arc
4040
let npmExecPath = process.env.npm_execpath || process.env.NPM_CLI_JS
4141
const npmExecArgs = ["install", "--production"]
4242

43-
const isYarn = npmExecPath != null || npmExecPath.includes("yarn")
43+
const isYarn = npmExecPath != null && npmExecPath.includes("yarn")
4444
if (!isYarn) {
4545
if (process.env.NPM_NO_BIN_LINKS === "true") {
4646
npmExecArgs.push("--no-bin-links")

test/src/globTest.ts

Lines changed: 5 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
import test from "./helpers/avaEx"
22
import { expectedWinContents } from "./helpers/expectedContents"
33
import { outputFile, symlink } from "fs-extra-p"
4-
import { assertPack, modifyPackageJson, getPossiblePlatforms, app, appThrows } from "./helpers/packTester"
4+
import { assertPack, modifyPackageJson, getPossiblePlatforms, app } from "./helpers/packTester"
55
import BluebirdPromise from "bluebird-lst-c"
66
import * as path from "path"
77
import { assertThat } from "./helpers/fileAssert"
@@ -148,16 +148,16 @@ test.ifNotCiOsx("ignore node_modules dev dep", () => {
148148
return BluebirdPromise.all([
149149
modifyPackageJson(projectDir, data => {
150150
data.devDependencies = Object.assign({
151-
"electron-osx-sign-tf": "*",
151+
"electron-macos-sign": "*",
152152
}, data.devDependencies)
153153
}),
154-
outputFile(path.join(projectDir, "node_modules", "electron-osx-sign-tf", "package.json"), "{}"),
154+
outputFile(path.join(projectDir, "node_modules", "electron-macos-sign", "package.json"), "{}"),
155155
outputFile(path.join(projectDir, "ignoreMe"), ""),
156156
])
157157
},
158158
packed: context => {
159159
return BluebirdPromise.all([
160-
assertThat(path.join(context.getResources(Platform.LINUX), "app", "node_modules", "electron-osx-sign-tf")).doesNotExist(),
160+
assertThat(path.join(context.getResources(Platform.LINUX), "app", "node_modules", "electron-macos-sign")).doesNotExist(),
161161
assertThat(path.join(context.getResources(Platform.LINUX), "app", "ignoreMe")).doesNotExist(),
162162
])
163163
},
@@ -318,24 +318,4 @@ test("extraResources - one-package", async () => {
318318
)) : null,
319319
})
320320
}
321-
})
322-
323-
test.ifDevOrLinuxCi("copy only js files - no asar", appThrows(/Application "package.json" does not exist/, {
324-
targets: Platform.LINUX.createTarget(DIR_TARGET),
325-
devMetadata: {
326-
build: {
327-
"files": ["**/*.js"],
328-
asar: false,
329-
}
330-
}
331-
}))
332-
333-
test.ifDevOrLinuxCi("copy only js files - asar", appThrows(/Application "package.json" in the /, {
334-
targets: Platform.LINUX.createTarget(DIR_TARGET),
335-
devMetadata: {
336-
build: {
337-
"files": ["**/*.js"],
338-
asar: true,
339-
}
340-
}
341-
}))
321+
})

test/src/macPackagerTest.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ import { BuildInfo } from "out/platformPackager"
77
import BluebirdPromise from "bluebird-lst-c"
88
import { assertThat } from "./helpers/fileAssert"
99
import { Platform, MacOptions, createTargets } from "out"
10-
import { SignOptions } from "electron-osx-sign-tf"
10+
import { SignOptions } from "electron-macos-sign"
1111
import { Arch } from "out"
1212
import { Target } from "out/platformPackager"
1313
import { DmgTarget } from "out/targets/dmg"

test/tsconfig.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@
2626
"../node_modules/ava-tf/types/generated.d.ts",
2727
"../node_modules/fs-extra-p/index.d.ts",
2828
"../node_modules/bluebird-lst-c/index.d.ts",
29-
"../node_modules/electron-osx-sign-tf/index.d.ts",
29+
"../node_modules/electron-macos-sign/index.d.ts",
3030
"../node_modules/@types/**/*.d.ts"
3131
],
3232
"exclude": [

tsconfig.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@
2929
"node_modules/fs-extra-p/index.d.ts",
3030
"node_modules/bluebird-lst-c/index.d.ts",
3131
"node_modules/7zip-bin/index.d.ts",
32-
"node_modules/electron-osx-sign-tf/index.d.ts"
32+
"node_modules/electron-macos-sign/index.d.ts"
3333
],
3434
"include": [
3535
"src/**/*.ts",

yarn.lock

Lines changed: 5 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -1535,7 +1535,7 @@ dateformat@^1.0.11, dateformat@^1.0.12:
15351535
get-stdin "^4.0.1"
15361536
meow "^3.3.0"
15371537

1538-
debug@^2.1.1, debug@^2.1.3, debug@^2.2.0, debug@2:
1538+
debug@^2.1.1, debug@^2.1.3, debug@^2.2.0, debug@^2.3.2, debug@2:
15391539
version "2.3.2"
15401540
resolved "https://registry.yarnpkg.com/debug/-/debug-2.3.2.tgz#94cb466ef7d6d2c7e5245cdd6e4104f2d0d70d30"
15411541
dependencies:
@@ -1670,17 +1670,16 @@ electron-download@2.1.2:
16701670
path-exists "^1.0.0"
16711671
rc "^1.1.2"
16721672

1673-
electron-osx-sign-tf@~1.1.0:
1674-
version "1.1.0"
1675-
resolved "https://registry.yarnpkg.com/electron-osx-sign-tf/-/electron-osx-sign-tf-1.1.0.tgz#f6d7ef8e94e47824ebd6a6c60d3464281d4abce9"
1673+
electron-macos-sign@~1.2.3:
1674+
version "1.2.3"
1675+
resolved "https://registry.yarnpkg.com/electron-macos-sign/-/electron-macos-sign-1.2.3.tgz#fb82b0f1e751a3ccd81c9507e1447ca83a1018d8"
16761676
dependencies:
16771677
bluebird "^3.4.6"
16781678
compare-version "^0.1.2"
1679-
debug "^2.2.0"
1679+
debug "^2.3.2"
16801680
isbinaryfile "^3.0.1"
16811681
minimist "^1.2.0"
16821682
plist "^2.0.1"
1683-
tempfile "^1.1.1"
16841683

16851684
empower-core@^0.6.1:
16861685
version "0.6.1"
@@ -3863,13 +3862,6 @@ tar@~2.2.1:
38633862
fstream "^1.0.2"
38643863
inherits "2"
38653864

3866-
tempfile@^1.1.1:
3867-
version "1.1.1"
3868-
resolved "https://registry.yarnpkg.com/tempfile/-/tempfile-1.1.1.tgz#5bcc4eaecc4ab2c707d8bc11d99ccc9a2cb287f2"
3869-
dependencies:
3870-
os-tmpdir "^1.0.0"
3871-
uuid "^2.0.1"
3872-
38733865
text-extensions@^1.0.0:
38743866
version "1.3.3"
38753867
resolved "https://registry.yarnpkg.com/text-extensions/-/text-extensions-1.3.3.tgz#fef0c8ce07f5bb3b8297bcf075304531754124bf"

0 commit comments

Comments
 (0)