Skip to content

Commit

Permalink
feat: base64-encoded P12 file instead of https link
Browse files Browse the repository at this point in the history
  • Loading branch information
develar committed May 9, 2016
1 parent 7d5b747 commit 3ab0e57
Show file tree
Hide file tree
Showing 5 changed files with 24 additions and 10 deletions.
11 changes: 8 additions & 3 deletions docs/Code Signing.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,9 @@ On a development machine set environment variable `CSC_NAME` (and `CSC_INSTALLER

| Env name | Description
| -------------- | -----------
| `CSC_LINK` | The HTTPS link to certificate (`*.p12` file).
| `CSC_LINK` | The HTTPS link (or base64-encoded data) to certificate (`*.p12` file).
| `CSC_KEY_PASSWORD` | The password to decrypt the certificate given in `CSC_LINK`.
| `CSC_INSTALLER_LINK` | *osx-only* The HTTPS link to certificate to sign Mac App Store build (`*.p12` file).
| `CSC_INSTALLER_LINK` | *osx-only* The HTTPS link (or base64-encoded data) to certificate to sign Mac App Store build (`*.p12` file).
| `CSC_INSTALLER_KEY_PASSWORD` | *osx-only* The password to decrypt the certificate given in `CSC_INSTALLER_LINK`.
| `CSC_NAME` | *osx-only* Name of certificate (to retrieve from login.keychain). Useful on a development machine (not on CI).
| `CSC_INSTALLER_NAME` | *osx-only* Name of installer certificate (to retrieve from login.keychain). Useful on a development machine (not on CI).
Expand All @@ -25,4 +25,9 @@ To sign app on build server you need to set `CSC_LINK`, `CSC_KEY_PASSWORD` (and
```
travis encrypt "CSC_LINK='https://drive.google.com/uc?export=download&id=***'" --add
travis encrypt 'CSC_KEY_PASSWORD=beAwareAboutBashEscaping!!!' --add
```
```

# Where to buy 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 (please note, it works, but we are waiting official confirmation).
2 changes: 1 addition & 1 deletion docs/Publishing Artifacts.md
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ But please consider using automatic rules instead of explicitly specifying `publ

* If CI server detected, — `onTagOrDraft`.

> **NOTICE**: _This is the recommended workflow._
**NOTICE**: _This is the recommended workflow._

1. [Draft a new release](https://help.github.com/articles/creating-releases/). Set the "Tag version" to the value of `version` in your application `package.json`, and prefix it with `v`. "Release title" can be anything you want.
- For example, if your application `package.json` version is `1.0`, your draft's "Tag version" would be `v1.0`.
Expand Down
15 changes: 12 additions & 3 deletions src/codeSign.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { exec } from "./util"
import { deleteFile } from "fs-extra-p"
import { deleteFile, outputFile } from "fs-extra-p"
import { download } from "./httpRequest"
import { tmpdir } from "os"
import * as path from "path"
Expand All @@ -25,6 +25,15 @@ export function generateKeychainName(): string {
return "csc-" + randomString() + ".keychain"
}

function downloadUrlOrBase64(urlOrBase64: string, destination: string): BluebirdPromise<any> {
if (urlOrBase64.startsWith("https://")) {
return download(urlOrBase64, destination)
}
else {
return outputFile(destination, Buffer.from(urlOrBase64, "base64"))
}
}

export function createKeychain(keychainName: string, cscLink: string, cscKeyPassword: string, cscILink?: string | null, cscIKeyPassword?: string | null, csaLink?: string | null): Promise<CodeSigningInfo> {
const certLinks = csaLink == null ? [] : [csaLink]
certLinks.push(cscLink)
Expand All @@ -35,7 +44,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([
BluebirdPromise.map(certPaths, (p, i) => download(certLinks[i], p)),
BluebirdPromise.map(certPaths, (p, i) => downloadUrlOrBase64(certLinks[i], p)),
BluebirdPromise.mapSeries([
["create-keychain", "-p", keychainPassword, keychainName],
["unlock-keychain", "-p", keychainPassword, keychainName],
Expand Down Expand Up @@ -121,6 +130,6 @@ export function deleteKeychain(keychainName: string, ignoreNotFound: boolean = t

export function downloadCertificate(cscLink: string): Promise<string> {
const certPath = path.join(tmpdir(), randomString() + ".p12")
return download(cscLink, certPath)
return downloadUrlOrBase64(cscLink, certPath)
.thenReturn(certPath)
}
2 changes: 1 addition & 1 deletion test/src/ArtifactPublisherTest.ts
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ function versionNumber() {
return getRandomInt(0, 99) + "." + Date.now() + "." + getRandomInt(0, 9)
}

const token = new Buffer("Y2Y5NDdhZDJhYzJlMzg1OGNiNzQzYzcwOWZhNGI0OTk2NWQ4ZDg3Yg==", "base64").toString()
const token = Buffer.from("Y2Y5NDdhZDJhYzJlMzg1OGNiNzQzYzcwOWZhNGI0OTk2NWQ4ZDg3Yg==", "base64").toString()
const iconPath = join(__dirname, "..", "fixtures", "test-app", "build", "icon.icns")

//test("GitHub unauthorized", async (t) => {
Expand Down
4 changes: 2 additions & 2 deletions test/src/helpers/codeSignData.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
export const CSC_LINK = "https://www.dropbox.com/s/86zaffzbao198xe/test.p12?dl=1"
export const CSC_LINK = "MIIJswIBAzCCCXoGCSqGSIb3DQEHAaCCCWsEgglnMIIJYzCCA/cGCSqGSIb3DQEHBqCCA+gwggPkAgEAMIID3QYJKoZIhvcNAQcBMBwGCiqGSIb3DQEMAQYwDgQI2SKzGO/uwG8CAggAgIIDsMYNqJuz2AeP3e0bKRMs8ZXLGEUlp32kxtt+qf7w1TyKjDq4DZ8YfycDhwPZ2+i75gB8htkyU7cKF1B4Je8x7vTHkJSAooPJyNqzpJCPEsGSN6XvO4Uq9JLPEG41PabOJQpb6FEEF6azReuEx9gf/SG39UsGb+mDYHOWJtCnR1Rlq0ZHTwEL+37NXjkzUz9C2jxccC+Dd0SEiwX9WBeulsJoWSWCpvmN3Ssp3r4E+ka8KCQHyg0YeYe6Z8QRtnv59RyPXsP9UAnqMTufc8xlZBQCFE+0Vvxatzvi3OI5yeVmne3OtzqJd3dWnPp6hi5+nJeQXbFfIOJdPahEV5XMxCRW0+8LTjOM8E7sIVUnlHhVHhZxN1QOZF4nvoEBOvf2C/SMLqVGT5RwBzdg7rc4BIXmwkqiORQj9d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cCETwJg71rs93S9bKLuCmKMBY+iW9mYatQdVrCsSnAoVQlLHmqp//pJ1ELZtQX0gPWhRXJFt+EmLYvIYia/dcd9yIBgAKZqm51eI4pOI+Xg/54BQG35uLRoGzCzN4GnzgQZJQ2sfWy8KVxQaiW0xGT7O57sintgleFQHAZcgc5ImgDsWD4NLSjvES4eUYML3CnxyiAzc0jyhs9Xsm5B+25XmSL/vcMxRw1NWvLIvg0h5CSjD4XuNdaK/aG5tv9uhN4DzVJx8LaEGGGEAQ/j5Re+MPgzkuGlmw6//ev9h0tUQqwLvn7Sfl/GqU2Rc9PaFcIjmdBWpA4DTJFBI75AOSDuB6gntw0hp+OKipI84Csv5Te8TrzmgakA/s5WVxemMm/YwxJkrYUiiFgIMdrOsMys1o/9gS5h0WipksxSDAhBgkqhkiG9w0BCRQxFB4SAFQAZQBzAHQAIABUAGUAcwB0MCMGCSqGSIb3DQEJFTEWBBSvQomPBYWDJ+g/PeAuSnApMDa0RjAwMCEwCQYFKw4DAhoFAAQU9YxuiT/5yg/tVaYH8kwDgw3HvFAECE50WYPZs6V2AgEB"
export const CSC_KEY_PASSWORD = "password"

export const CSC_INSTALLER_LINK = "https://www.dropbox.com/s/2drwf5owgoqxkr3/test-installer.p12?dl=1"
export const CSC_INSTALLER_LINK = "https://drive.google.com/uc?export=download&id=0Bz3JwZ-jqfRONTkzTGlsMkM2TlE"
export const CSC_INSTALLER_KEY_PASSWORD = "password"

export const CSC_NAME = "Test Test"

0 comments on commit 3ab0e57

Please sign in to comment.