From bffbbf1586ad23920cce2b69111327557682c69e Mon Sep 17 00:00:00 2001 From: Vladimir Krivosheev Date: Mon, 23 May 2016 16:22:27 +0200 Subject: [PATCH] fix: import bundled certs into login.keychain Closes #398 --- .gitattributes | 3 +- .idea/runConfigurations/CodeSignTest.xml | 2 +- certs/AppleWWDRCA.cer | Bin 1062 -> 0 bytes certs/bundle.crt | 97 ----------------------- certs/create.sh | 20 ++++- certs/root_certs.keychain | 3 + docs/Code Signing.md | 3 +- package.json | 2 +- src/codeSign.ts | 52 ++++++++---- src/packager.ts | 6 +- src/util.ts | 4 +- 11 files changed, 67 insertions(+), 125 deletions(-) delete mode 100644 certs/AppleWWDRCA.cer delete mode 100644 certs/bundle.crt create mode 100644 certs/root_certs.keychain diff --git a/.gitattributes b/.gitattributes index f7dc612ed50..67ce1e1abc9 100755 --- a/.gitattributes +++ b/.gitattributes @@ -2,4 +2,5 @@ *.ico filter=lfs diff=lfs merge=lfs -text *.icns filter=lfs diff=lfs merge=lfs -text vendor/**/* filter=lfs diff=lfs merge=lfs -text -*.gif filter=lfs diff=lfs merge=lfs -text \ No newline at end of file +*.gif filter=lfs diff=lfs merge=lfs -text +*.keychain filter=lfs diff=lfs merge=lfs -text diff --git a/.idea/runConfigurations/CodeSignTest.xml b/.idea/runConfigurations/CodeSignTest.xml index 46be966e804..894447848af 100644 --- a/.idea/runConfigurations/CodeSignTest.xml +++ b/.idea/runConfigurations/CodeSignTest.xml @@ -1,5 +1,5 @@ - + diff --git a/certs/AppleWWDRCA.cer b/certs/AppleWWDRCA.cer deleted file mode 100644 index d2bb1da64122c864c872d9b711b176d042462748..0000000000000000000000000000000000000000 GIT binary patch literal 0 HcmV?d00001 literal 1062 zcmXqLVo@?^V&+=F%*4pV#KCxP&k@Vq1p)@VY@Awc9&O)w85vnw84QvPxeYkkm_u3E zgqcEv4TTK^K^!h&F2{m`oKywRyktE?H3JopAh)nAM9?|4s3bEjGdZy&Ge1wkv9u&3 zzbLb$(ooDm1f-5xm=~fhC_leM!P(J3PMp`!*ucoZ+{nZl`k>Qj@$g1r8WvHYTX!VypjWG%{)c-lQVYXRuCJE(pY=;r$WxRF4-br${9`c}_k`!An>Li0EopDe zv*^E}E$UaTdLwGTU-QAd$KGuPNJ^ruh+PumVL-h)reU3&vOc4_NAnbP|3 z#gVzkGL~*w{3pGxU>8%Qce&F<%bj1(KJXzgbzkmy4MuTzafLDk420{ zq(fbtbLBRPgzh)5cYSk@JQ@_Tc)I~VNLrYY@jnZz0W**?kOv7Uvq%_-HHc_m$aJ4l z#`*6{cCVhpvhVJ`^&D{qdLRYzEb0cT2FeQ*7s$8CW|Wi^Sn2C07v<Nhma(=FU z5ipVI0fh|sKiL>2Sz0$ga7&Wk^6MMZpzW` ze<$2-^n%rNMP7I9$xNP|H^ujq>s(2H^mkUSRbjJu1>%3p6qBF+hu?6 zedkq{<@Qo*x8F5!lFt%JA<5kEuT>H4)frt++IqZRKk^h=we)T%!^(BLy$#kqT(EJE zX2Ubi@~8Vu7BQZxzw?Oene~p{Z+0b3{mh!|*mRcPTGnUklH03)o}Bv9|B3H&wV91C z_x#+Vd5N(q?V(=JH^r`_KPnzJuG@ck!rYZ>Kd=95AvG=CKqhc$%$vflrY$-AJfiXd D2`7-6 diff --git a/certs/bundle.crt b/certs/bundle.crt deleted file mode 100644 index c2bcef21ae8..00000000000 --- a/certs/bundle.crt +++ /dev/null @@ -1,97 +0,0 @@ ------BEGIN CERTIFICATE----- -MIIF2DCCA8CgAwIBAgIQbDvSft08lJ6Vjiips8dXoDANBgkqhkiG9w0BAQsFADB9 -MQswCQYDVQQGEwJJTDEWMBQGA1UEChMNU3RhcnRDb20gTHRkLjErMCkGA1UECxMi -U2VjdXJlIERpZ2l0YWwgQ2VydGlmaWNhdGUgU2lnbmluZzEpMCcGA1UEAxMgU3Rh -cnRDb20gQ2VydGlmaWNhdGlvbiBBdXRob3JpdHkwHhcNMTUxMjE2MDEwMDA1WhcN -MzAxMjE2MDEwMDA1WjB1MQswCQYDV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QtpO824P0k90I0cExRoLpsNmq2wGeKe0nw5d4hvI/17hPxEbbW6a3CS -VWyUsdg3/alZHbRjstwTzXiOJTXBmo83hC7URczj9cyNc6jjOm3nlZRwV5FQtm3v -c3JPLwKHYOLqIqHtPv3Ri2aNLnJtT8ZdNe6TqJjSZ2rp2hnNAoP5dPxfehgEKB7d -IjM7dmxHBV3VUv4OunbzgxDHbjBfp2DH+nQnMZsog+0hihvxI1KE7ZW8rTqlo0IB -nbw= ------END CERTIFICATE----- diff --git a/certs/create.sh b/certs/create.sh index f9558a72028..4067a89b2e7 100755 --- a/certs/create.sh +++ b/certs/create.sh @@ -1,5 +1,17 @@ -> bundle.crt -curl https://www.startssl.com/certs/sca.code2.crt >> bundle.crt -curl https://www.startssl.com/certs/sca.code3.crt >> bundle.crt +#!/usr/bin/env bash -curl https://repository.certum.pl/cscasha2.pem >> bundle.crt \ No newline at end of file +> /tmp/bundle.crt +curl https://www.startssl.com/certs/sca.code2.crt >> /tmp/bundle.crt +curl https://www.startssl.com/certs/sca.code3.crt >> /tmp/bundle.crt + +curl https://repository.certum.pl/cscasha2.pem >> /tmp/bundle.crt + + +rm -rf $PWD/root_certs.keychain +security create-keychain -p pass $PWD/root_certs.keychain +security set-keychain-settings -t 86400 -u $PWD/root_certs.keychain + +security import /tmp/bundle.crt -k $PWD/root_certs.keychain -T /usr/bin/codesign -T /usr/bin/productbuild + +curl https://developer.apple.com/certificationauthority/AppleWWDRCA.cer > /tmp/AppleWWDRCA.cer +security import /tmp/AppleWWDRCA.cer -k $PWD/root_certs.keychain -T /usr/bin/codesign -T /usr/bin/productbuild \ No newline at end of file diff --git a/certs/root_certs.keychain b/certs/root_certs.keychain new file mode 100644 index 00000000000..aec2067511e --- /dev/null +++ b/certs/root_certs.keychain @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:d63fbb2e912ca7b375a6edefcdf1bff92b25f311fdb67f226c03bd91e744ab54 +size 31944 diff --git a/docs/Code Signing.md b/docs/Code Signing.md index c9655c90789..2b0569d18cd 100644 --- a/docs/Code Signing.md +++ b/docs/Code Signing.md @@ -29,5 +29,4 @@ To sign app on build server you need to set `CSC_LINK`, `CSC_KEY_PASSWORD` (and In case of AppVeyor, don't forget to click on lock icon to “Toggle variable encryption”. # Where to Buy Code Signing Certificate -[StartSSL](https://startssl.com/Support?v=34) is recommended. -It can be used to sign OS X app also, so, you don't need to buy Apple Certificate in addition. \ No newline at end of file +[StartSSL](https://startssl.com/Support?v=34) is recommended. \ No newline at end of file diff --git a/package.json b/package.json index 544daefb2a1..2418477add1 100644 --- a/package.json +++ b/package.json @@ -6,7 +6,7 @@ "files": [ "out", "templates", - "certs" + "certs/root_certs.keychain" ], "bin": { "build": "./out/build-cli.js", diff --git a/src/codeSign.ts b/src/codeSign.ts index b459f86adb8..c0052e5720b 100644 --- a/src/codeSign.ts +++ b/src/codeSign.ts @@ -1,11 +1,12 @@ -import { exec } from "./util" -import { deleteFile, outputFile } from "fs-extra-p" +import { exec, getTempName } from "./util" +import { deleteFile, outputFile, copy, rename } from "fs-extra-p" import { download } from "./httpRequest" import { tmpdir } from "os" import * as path from "path" import { executeFinally, all } from "./promise" import { Promise as BluebirdPromise } from "bluebird" import { randomBytes } from "crypto" +import { homedir } from "os" //noinspection JSUnusedLocalSymbols const __awaiter = require("./awaiter") @@ -34,7 +35,38 @@ function downloadUrlOrBase64(urlOrBase64: string, destination: string): Bluebird } } -export function createKeychain(keychainName: string, cscLink: string, cscKeyPassword: string, cscILink?: string | null, cscIKeyPassword?: string | null, csaLink?: string | null): Promise { +let bundledCertKeychainAdded = false + +export async function createKeychain(keychainName: string, cscLink: string, cscKeyPassword: string, cscILink?: string | null, cscIKeyPassword?: string | null, csaLink?: string | null): Promise { + if (!bundledCertKeychainAdded) { + // "Note that filename will not be searched to resolve the signing identity's certificate chain unless it is also on the user's keychain search list." + // but "security list-keychains" doesn't support add - we should 1) get current list 2) set new list - it is very bad http://stackoverflow.com/questions/10538942/add-a-keychain-to-search-list + // "overly complicated and introduces a race condition." + // https://github.com/electron-userland/electron-builder/issues/398 + + bundledCertKeychainAdded = true + + // copy to temp and then atomic rename to final path + const tmpKeychainPath = path.join(homedir(), ".cache", getTempName("electron_builder_root_certs")) + const keychainPath = path.join(homedir(), ".cache", "electron_builder_root_certs.keychain") + const results = await BluebirdPromise.all | string>([ + exec("security", ["list-keychains"]), + copy(path.join(__dirname, "..", "certs", "root_certs.keychain"), tmpKeychainPath) + .then(() => rename(tmpKeychainPath, keychainPath)), + ]) + const list = (results[0])[0] + .split("\n") + .map(it => { + let r = it.trim() + return r.substring(1, r.length - 1) + }) + .filter(it => it.length > 0) + + if (!list.includes(keychainPath)) { + await exec("security", ["list-keychains", "-d", "user", "-s", keychainPath]) + } + } + const certLinks = csaLink == null ? [] : [csaLink] certLinks.push(cscLink) if (cscILink != null) { @@ -43,7 +75,7 @@ export function createKeychain(keychainName: string, cscLink: string, cscKeyPass const certPaths = certLinks.map(it => path.join(tmpdir(), randomString() + (it.endsWith(".cer") ? ".cer" : ".p12"))) const keychainPassword = randomString() - return executeFinally(BluebirdPromise.all([ + return await executeFinally(BluebirdPromise.all([ BluebirdPromise.map(certPaths, (p, i) => downloadUrlOrBase64(certLinks[i], p)), BluebirdPromise.mapSeries([ ["create-keychain", "-p", keychainPassword, keychainName], @@ -51,7 +83,7 @@ export function createKeychain(keychainName: string, cscLink: string, cscKeyPass ["set-keychain-settings", "-t", "3600", "-u", keychainName] ], it => exec("security", it)) ]) - .then(() => importCerts(keychainName, certPaths, [cscKeyPassword, cscIKeyPassword].filter(it => it != null), csaLink == null)), + .then(() => importCerts(keychainName, certPaths, [cscKeyPassword, cscIKeyPassword].filter(it => it != null))), errorOccurred => { const tasks = certPaths.map(it => deleteFile(it, true)) if (errorOccurred) { @@ -61,16 +93,8 @@ export function createKeychain(keychainName: string, cscLink: string, cscKeyPass }) } -async function importCerts(keychainName: string, paths: Array, keyPasswords: Array, importBundledCerts: boolean): Promise { +async function importCerts(keychainName: string, paths: Array, keyPasswords: Array): Promise { const certFiles = paths.slice(0, -keyPasswords.length) - if (importBundledCerts) { - const bundledCertsPath = path.join(__dirname, "..", "certs") - certFiles.push( - path.join(bundledCertsPath, "AppleWWDRCA.cer"), - path.join(bundledCertsPath, "bundle.crt") - ) - } - for (let file of certFiles) { await exec("security", ["import", file, "-k", keychainName, "-T", "/usr/bin/codesign"]) } diff --git a/src/packager.ts b/src/packager.ts index c788be5ac85..2fd0029b7c8 100644 --- a/src/packager.ts +++ b/src/packager.ts @@ -77,7 +77,7 @@ export class Packager implements BuildInfo { // custom packager - don't check wine let checkWine = this.options.platformPackagerFactory == null for (let platform of platforms) { - let wineCheck: Promise | null = null + let wineCheck: Promise | null = null if (checkWine && process.platform !== "win32" && platform === Platform.WINDOWS) { wineCheck = exec("wine", ["--version"]) } @@ -228,14 +228,14 @@ function checkConflictingOptions(options: any) { } } -async function checkWineVersion(checkPromise: Promise) { +async function checkWineVersion(checkPromise: Promise) { function wineError(prefix: string): string { return `${prefix}, please see https://github.com/electron-userland/electron-builder/wiki/Multi-Platform-Build#${(process.platform === "linux" ? "linux" : "os-x")}` } let wineVersion: string try { - wineVersion = (await checkPromise)[0].toString().trim() + wineVersion = (await checkPromise)[0].trim() } catch (e) { if (e.code === "ENOENT") { diff --git a/src/util.ts b/src/util.ts index 3352847bd89..2526d448e16 100644 --- a/src/util.ts +++ b/src/util.ts @@ -67,12 +67,12 @@ export interface ExecOptions extends BaseExecOptions { killSignal?: string } -export function exec(file: string, args?: Array | null, options?: ExecOptions): BluebirdPromise { +export function exec(file: string, args?: Array | null, options?: ExecOptions): BluebirdPromise { if (debug.enabled) { debug(`Executing ${file} ${args == null ? "" : args.join(" ")}`) } - return new BluebirdPromise((resolve, reject) => { + return new BluebirdPromise((resolve, reject) => { execFile(file, args, options, function (error, stdout, stderr) { if (error == null) { resolve([stdout, stderr])