Skip to content

Commit

Permalink
fix: App rejected when Mac Developer certificate is in keychain
Browse files Browse the repository at this point in the history
  • Loading branch information
develar committed Nov 11, 2016
1 parent 6ce683f commit 9edadb5
Show file tree
Hide file tree
Showing 9 changed files with 21 additions and 48 deletions.
4 changes: 2 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -67,9 +67,9 @@
"chromium-pickle-js": "^0.2.0",
"cli-cursor": "^1.0.2",
"cuint": "^0.2.2",
"debug": "^2.2.0",
"debug": "^2.3.2",
"electron-download": "2.1.2",
"electron-osx-sign-tf": "~1.1.0",
"electron-macos-sign": "~1.2.3",
"fs-extra-p": "^2.0.6",
"hosted-git-info": "^2.1.5",
"ini": "^1.3.4",
Expand Down
2 changes: 1 addition & 1 deletion src/codeSign.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ import BluebirdPromise from "bluebird-lst-c"
import { randomBytes } from "crypto"
import { TmpDir } from "./util/tmp"

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

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

Expand Down
7 changes: 4 additions & 3 deletions src/macPackager.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,9 @@ import { MasBuildOptions, MacOptions } from "./options/macOptions"
import * as path from "path"
import BluebirdPromise from "bluebird-lst-c"
import { log, warn, task } from "./util/log"
import { createKeychain, CodeSigningInfo, findIdentity } from "./codeSign"
import { createKeychain, CodeSigningInfo, findIdentity, appleCertificatePrefixes } from "./codeSign"
import { deepAssign } from "./util/deepAssign"
import { signAsync, SignOptions } from "electron-osx-sign-tf"
import { signAsync, SignOptions } from "electron-macos-sign"
import { DmgTarget } from "./targets/dmg"
import { createCommonTarget, DEFAULT_TARGET, DIR_TARGET } from "./targets/targetFactory"
import { AppInfo } from "./appInfo"
Expand Down Expand Up @@ -126,11 +126,12 @@ export default class MacPackager extends PlatformPackager<MacOptions> {

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

const resourceList = await this.resourceList
Expand Down
2 changes: 1 addition & 1 deletion src/yarn.ts
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ export function installDependencies(appDir: string, electronVersion: string, arc
let npmExecPath = process.env.npm_execpath || process.env.NPM_CLI_JS
const npmExecArgs = ["install", "--production"]

const isYarn = npmExecPath != null || npmExecPath.includes("yarn")
const isYarn = npmExecPath != null && npmExecPath.includes("yarn")
if (!isYarn) {
if (process.env.NPM_NO_BIN_LINKS === "true") {
npmExecArgs.push("--no-bin-links")
Expand Down
30 changes: 5 additions & 25 deletions test/src/globTest.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import test from "./helpers/avaEx"
import { expectedWinContents } from "./helpers/expectedContents"
import { outputFile, symlink } from "fs-extra-p"
import { assertPack, modifyPackageJson, getPossiblePlatforms, app, appThrows } from "./helpers/packTester"
import { assertPack, modifyPackageJson, getPossiblePlatforms, app } from "./helpers/packTester"
import BluebirdPromise from "bluebird-lst-c"
import * as path from "path"
import { assertThat } from "./helpers/fileAssert"
Expand Down Expand Up @@ -148,16 +148,16 @@ test.ifNotCiOsx("ignore node_modules dev dep", () => {
return BluebirdPromise.all([
modifyPackageJson(projectDir, data => {
data.devDependencies = Object.assign({
"electron-osx-sign-tf": "*",
"electron-macos-sign": "*",
}, data.devDependencies)
}),
outputFile(path.join(projectDir, "node_modules", "electron-osx-sign-tf", "package.json"), "{}"),
outputFile(path.join(projectDir, "node_modules", "electron-macos-sign", "package.json"), "{}"),
outputFile(path.join(projectDir, "ignoreMe"), ""),
])
},
packed: context => {
return BluebirdPromise.all([
assertThat(path.join(context.getResources(Platform.LINUX), "app", "node_modules", "electron-osx-sign-tf")).doesNotExist(),
assertThat(path.join(context.getResources(Platform.LINUX), "app", "node_modules", "electron-macos-sign")).doesNotExist(),
assertThat(path.join(context.getResources(Platform.LINUX), "app", "ignoreMe")).doesNotExist(),
])
},
Expand Down Expand Up @@ -318,24 +318,4 @@ test("extraResources - one-package", async () => {
)) : null,
})
}
})

test.ifDevOrLinuxCi("copy only js files - no asar", appThrows(/Application "package.json" does not exist/, {
targets: Platform.LINUX.createTarget(DIR_TARGET),
devMetadata: {
build: {
"files": ["**/*.js"],
asar: false,
}
}
}))

test.ifDevOrLinuxCi("copy only js files - asar", appThrows(/Application "package.json" in the /, {
targets: Platform.LINUX.createTarget(DIR_TARGET),
devMetadata: {
build: {
"files": ["**/*.js"],
asar: true,
}
}
}))
})
2 changes: 1 addition & 1 deletion test/src/macPackagerTest.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ import { BuildInfo } from "out/platformPackager"
import BluebirdPromise from "bluebird-lst-c"
import { assertThat } from "./helpers/fileAssert"
import { Platform, MacOptions, createTargets } from "out"
import { SignOptions } from "electron-osx-sign-tf"
import { SignOptions } from "electron-macos-sign"
import { Arch } from "out"
import { Target } from "out/platformPackager"
import { DmgTarget } from "out/targets/dmg"
Expand Down
2 changes: 1 addition & 1 deletion test/tsconfig.json
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@
"../node_modules/ava-tf/types/generated.d.ts",
"../node_modules/fs-extra-p/index.d.ts",
"../node_modules/bluebird-lst-c/index.d.ts",
"../node_modules/electron-osx-sign-tf/index.d.ts",
"../node_modules/electron-macos-sign/index.d.ts",
"../node_modules/@types/**/*.d.ts"
],
"exclude": [
Expand Down
2 changes: 1 addition & 1 deletion tsconfig.json
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@
"node_modules/fs-extra-p/index.d.ts",
"node_modules/bluebird-lst-c/index.d.ts",
"node_modules/7zip-bin/index.d.ts",
"node_modules/electron-osx-sign-tf/index.d.ts"
"node_modules/electron-macos-sign/index.d.ts"
],
"include": [
"src/**/*.ts",
Expand Down
18 changes: 5 additions & 13 deletions yarn.lock
Original file line number Diff line number Diff line change
Expand Up @@ -1535,7 +1535,7 @@ dateformat@^1.0.11, dateformat@^1.0.12:
get-stdin "^4.0.1"
meow "^3.3.0"

debug@^2.1.1, debug@^2.1.3, debug@^2.2.0, debug@2:
debug@^2.1.1, debug@^2.1.3, debug@^2.2.0, debug@^2.3.2, debug@2:
version "2.3.2"
resolved "https://registry.yarnpkg.com/debug/-/debug-2.3.2.tgz#94cb466ef7d6d2c7e5245cdd6e4104f2d0d70d30"
dependencies:
Expand Down Expand Up @@ -1670,17 +1670,16 @@ electron-download@2.1.2:
path-exists "^1.0.0"
rc "^1.1.2"

electron-osx-sign-tf@~1.1.0:
version "1.1.0"
resolved "https://registry.yarnpkg.com/electron-osx-sign-tf/-/electron-osx-sign-tf-1.1.0.tgz#f6d7ef8e94e47824ebd6a6c60d3464281d4abce9"
electron-macos-sign@~1.2.3:
version "1.2.3"
resolved "https://registry.yarnpkg.com/electron-macos-sign/-/electron-macos-sign-1.2.3.tgz#fb82b0f1e751a3ccd81c9507e1447ca83a1018d8"
dependencies:
bluebird "^3.4.6"
compare-version "^0.1.2"
debug "^2.2.0"
debug "^2.3.2"
isbinaryfile "^3.0.1"
minimist "^1.2.0"
plist "^2.0.1"
tempfile "^1.1.1"

empower-core@^0.6.1:
version "0.6.1"
Expand Down Expand Up @@ -3863,13 +3862,6 @@ tar@~2.2.1:
fstream "^1.0.2"
inherits "2"

tempfile@^1.1.1:
version "1.1.1"
resolved "https://registry.yarnpkg.com/tempfile/-/tempfile-1.1.1.tgz#5bcc4eaecc4ab2c707d8bc11d99ccc9a2cb287f2"
dependencies:
os-tmpdir "^1.0.0"
uuid "^2.0.1"

text-extensions@^1.0.0:
version "1.3.3"
resolved "https://registry.yarnpkg.com/text-extensions/-/text-extensions-1.3.3.tgz#fef0c8ce07f5bb3b8297bcf075304531754124bf"
Expand Down

0 comments on commit 9edadb5

Please sign in to comment.