Skip to content

Commit

Permalink
fix(codeSign): signing with "Mac Developer" failed #1103
Browse files Browse the repository at this point in the history
  • Loading branch information
develar committed Jan 12, 2017
1 parent 3e1b970 commit 88682e8
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 13 deletions.
12 changes: 4 additions & 8 deletions packages/electron-builder/src/codeSign.ts
Original file line number Diff line number Diff line change
Expand Up @@ -206,26 +206,22 @@ async function _findIdentity(type: CertType, qualifier?: string | null, keychain
return null
}

export async function findIdentity(certType: CertType, qualifier?: string | null, keychain?: string | null): Promise<string | null> {
export function findIdentity(certType: CertType, qualifier?: string | null, keychain?: string | null): Promise<string | null> {
let identity = process.env.CSC_NAME || qualifier
if (isEmptyOrSpaces(identity)) {
if (keychain == null && !isCi && process.env.CSC_IDENTITY_AUTO_DISCOVERY === "false") {
return null
return BluebirdPromise.resolve(null)
}
else {
return await _findIdentity(certType, null, keychain)
return _findIdentity(certType, null, keychain)
}
}
else {
identity = identity.trim()
for (const prefix of appleCertificatePrefixes) {
checkPrefix(identity, prefix)
}
const result = await _findIdentity(certType, identity, keychain)
if (result == null) {
throw new Error(`Identity name "${identity}" is specified, but no valid identity with this name in the keychain`)
}
return result
return _findIdentity(certType, identity, keychain)
}
}

Expand Down
10 changes: 7 additions & 3 deletions packages/electron-builder/src/macPackager.ts
Original file line number Diff line number Diff line change
Expand Up @@ -104,15 +104,19 @@ export default class MacPackager extends PlatformPackager<MacOptions> {

const keychainName = (await this.codeSigningInfo).keychainName
const isMas = masOptions != null
const masQualifier = isMas ? (masOptions!!.identity || this.platformSpecificBuildOptions.identity) : null
const qualifier = this.platformSpecificBuildOptions.identity
const masQualifier = isMas ? (masOptions!!.identity || qualifier) : null

let name = await findIdentity(isMas ? "3rd Party Mac Developer Application" : "Developer ID Application", isMas ? masQualifier : this.platformSpecificBuildOptions.identity, keychainName)
let name = await findIdentity(isMas ? "3rd Party Mac Developer Application" : "Developer ID Application", isMas ? masQualifier : qualifier, keychainName)
if (name == null) {
if (!isMas) {
name = await findIdentity("Mac Developer", this.platformSpecificBuildOptions.identity, keychainName)
name = await findIdentity("Mac Developer", qualifier, keychainName)
if (name != null) {
warn("Mac Developer is used to sign app — it is only for development and testing, not for production")
}
else if (qualifier != null) {
throw new Error(`Identity name "${qualifier}" is specified, but no valid identity with this name in the keychain`)
}
}

if (name == null) {
Expand Down
3 changes: 1 addition & 2 deletions test/src/windows/nsisTest.ts
Original file line number Diff line number Diff line change
Expand Up @@ -165,8 +165,7 @@ test.ifDevOrLinuxCi("custom script", app({targets: nsisTarget}, {
packed: context => assertThat(path.join(context.projectDir, "build", "customInstallerScript")).isFile(),
}))

// todo why failed on CI?
test.ifNotCi("allowToChangeInstallationDirectory", app({
test("allowToChangeInstallationDirectory", app({
targets: nsisTarget,
appMetadata: {
name: "test-custom-inst-dir",
Expand Down

0 comments on commit 88682e8

Please sign in to comment.