diff --git a/src/builder.ts b/src/builder.ts index b4961c25e22..b1da70709e3 100644 --- a/src/builder.ts +++ b/src/builder.ts @@ -32,6 +32,9 @@ export function build(options: BuildOptions = {}): Promise { if (options.cscLink == null) { options.cscLink = process.env.CSC_LINK } + if (options.csaLink == null) { + options.csaLink = process.env.CSA_LINK + } if (options.cscKeyPassword == null) { options.cscKeyPassword = process.env.CSC_KEY_PASSWORD } @@ -95,4 +98,4 @@ export function build(options: BuildOptions = {}): Promise { return null } }) -} \ No newline at end of file +} diff --git a/src/codeSign.ts b/src/codeSign.ts index bbb8d2c84be..de9f2fccce3 100644 --- a/src/codeSign.ts +++ b/src/codeSign.ts @@ -24,13 +24,13 @@ export function generateKeychainName(): string { return "csc-" + randomString() + ".keychain" } -export function createKeychain(keychainName: string, cscLink: string, cscKeyPassword: string): Promise { - const appleCertPath = path.join(tmpdir(), randomString() + ".cer") +export function createKeychain(keychainName: string, cscLink: string, cscKeyPassword: string, csaLink: string): Promise { + const authorityCertPath = path.join(tmpdir(), randomString() + ".cer") const developerCertPath = path.join(tmpdir(), randomString() + ".p12") const keychainPassword = randomString() return executeFinally(Promise.all([ - download("https://developer.apple.com/certificationauthority/AppleWWDRCA.cer", appleCertPath), + download(csaLink || "https://developer.apple.com/certificationauthority/AppleWWDRCA.cer", authorityCertPath), download(cscLink, developerCertPath), BluebirdPromise.mapSeries([ ["create-keychain", "-p", keychainPassword, keychainName], @@ -38,9 +38,9 @@ export function createKeychain(keychainName: string, cscLink: string, cscKeyPass ["set-keychain-settings", "-t", "3600", "-u", keychainName] ], it => exec("security", it)) ]) - .then(() => importCerts(keychainName, appleCertPath, developerCertPath, cscKeyPassword)), + .then(() => importCerts(keychainName, authorityCertPath, developerCertPath, cscKeyPassword)), error => { - const tasks = [deleteFile(appleCertPath, true), deleteFile(developerCertPath, true)] + const tasks = [deleteFile(authorityCertPath, true), deleteFile(developerCertPath, true)] if (error != null) { tasks.push(deleteKeychain(keychainName)) } @@ -48,8 +48,8 @@ export function createKeychain(keychainName: string, cscLink: string, cscKeyPass }) } -async function importCerts(keychainName: string, appleCertPath: string, developerCertPath: string, cscKeyPassword: string): Promise { - await exec("security", ["import", appleCertPath, "-k", keychainName, "-T", "/usr/bin/codesign"]) +async function importCerts(keychainName: string, authorityCertPath: string, developerCertPath: string, cscKeyPassword: string): Promise { + await exec("security", ["import", authorityCertPath, "-k", keychainName, "-T", "/usr/bin/codesign"]) await exec("security", ["import", developerCertPath, "-k", keychainName, "-T", "/usr/bin/codesign", "-P", cscKeyPassword]) let cscName = await extractCommonName(cscKeyPassword, developerCertPath) return { @@ -97,4 +97,4 @@ export function downloadCertificate(cscLink: string): Promise { const certPath = path.join(tmpdir(), randomString() + ".p12") return download(cscLink, certPath) .thenReturn(certPath) -} \ No newline at end of file +} diff --git a/src/macPackager.ts b/src/macPackager.ts index d832a1ee106..f2307b545c2 100644 --- a/src/macPackager.ts +++ b/src/macPackager.ts @@ -17,7 +17,7 @@ export default class MacPackager extends PlatformPackager if (this.options.cscLink != null && this.options.cscKeyPassword != null) { const keychainName = generateKeychainName() cleanupTasks.push(() => deleteKeychain(keychainName)) - this.codeSigningInfo = createKeychain(keychainName, this.options.cscLink, this.options.cscKeyPassword) + this.codeSigningInfo = createKeychain(keychainName, this.options.cscLink, this.options.cscKeyPassword, this.options.csaLink) } else { this.codeSigningInfo = BluebirdPromise.resolve(null) @@ -106,4 +106,4 @@ export default class MacPackager extends PlatformPackager }) .thenReturn(outDir + "/" + resultPath) } -} \ No newline at end of file +} diff --git a/src/platformPackager.ts b/src/platformPackager.ts index d5027e41fe5..829f16a82b1 100644 --- a/src/platformPackager.ts +++ b/src/platformPackager.ts @@ -42,6 +42,7 @@ export interface PackagerOptions { projectDir?: string cscLink?: string + csaLink?: string cscKeyPassword?: string } @@ -131,4 +132,4 @@ export abstract class PlatformPackager implements ProjectMetadataProvider { } abstract packageInDistributableFormat(outDir: string, appOutDir: string, arch: string): Promise -} \ No newline at end of file +}