Skip to content

Commit af53ad0

Browse files
feat: new per-file API with defaults that work out of the box (#253)
BREAKING CHANGE: The entire API changed
1 parent 6bdaabf commit af53ad0

18 files changed

+291
-443
lines changed

.circleci/config.yml

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -28,21 +28,21 @@ version: 2
2828
jobs:
2929
test-mac-16:
3030
macos:
31-
xcode: "11.0.0"
31+
xcode: "11.6.0"
3232
environment:
3333
NODE_VERSION: "16"
3434
<<: *steps-test
3535

3636
test-mac-14:
3737
macos:
38-
xcode: "11.0.0"
38+
xcode: "11.6.0"
3939
environment:
4040
NODE_VERSION: "14"
4141
<<: *steps-test
4242

4343
test-mac-12:
4444
macos:
45-
xcode: "11.0.0"
45+
xcode: "11.6.0"
4646
environment:
4747
NODE_VERSION: "12"
4848
<<: *steps-test

README.md

Lines changed: 17 additions & 55 deletions
Original file line numberDiff line numberDiff line change
@@ -77,10 +77,7 @@ The examples below assume that `--pre-auto-entitlements` is enabled.
7777
electron-osx-sign path/to/my.app --provisioning-profile=path/to/my.provisionprofile
7878
```
7979

80-
- To specify the entitlements file:
81-
```sh
82-
electron-osx-sign path/to/my.app --entitlements=path/to/my.entitlements
83-
```
80+
- To specify custom entitlements files you have to use the JS API.
8481

8582
- It is recommended to make use of `--version` while signing legacy versions of Electron:
8683
```sh
@@ -151,34 +148,21 @@ Needs file extension `.app`.
151148
Path to additional binaries that will be signed along with built-ins of Electron.
152149
Default to `undefined`.
153150

154-
`entitlements` - *String*
155-
156-
Path to entitlements file for signing the app.
157-
Default to built-in entitlements file, Sandbox enabled for Mac App Store platform.
158-
See [default.entitlements.mas.plist](https://github.com/electron-userland/electron-osx-sign/blob/master/default.entitlements.mas.plist) or [default.entitlements.darwin.plist](https://github.com/electron-userland/electron-osx-sign/blob/master/default.entitlements.darwin.plist) with respect to your platform.
159-
160-
`entitlements-inherit` - *String*
161-
162-
Path to child entitlements which inherit the security settings for signing frameworks and bundles of a distribution. *This option only applies when signing with entitlements.*
163-
See [default.entitlements.mas.inherit.plist](https://github.com/electron-userland/electron-osx-sign/blob/master/default.entitlements.mas.inherit.plist) or [default.entitlements.darwin.inherit.plist](https://github.com/electron-userland/electron-osx-sign/blob/master/default.entitlements.darwin.inherit.plist) with respect to your platform.
151+
`optionsForFile` - *Function*
164152

165-
`entitlements-loginhelper` - *String*
153+
Function that receives the path to a file and can return the entitlements to use for that file to override the default behavior. The
154+
object this function returns can include any of the following optional keys.
166155

167-
Path to login helper entitlement file. When using App Sandbox, the inherited entitlement should not be used since this is a standalone executable. *This option only applies when signing with entitlements.*
168-
Default to the same entitlements file used for signing the app bundle.
169-
170-
`entitlementsForFile` - *Function*
171-
172-
Function that receives the path to a file and the current codesign arguments as parameters. If you wish to override the entitlements used for this file path this function should return the absolute path to a different entitlements file.
156+
| Option | Description | Usage Example |
157+
|-------------------|-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|-----------------------------------------------------------------|
158+
| `entitlements` | String specifying the path to an `entitlements.plist` file. Will default to built-in entitlements files. Can also be an array of entitlement keys that osx-sign will write to an entitlements file for you. | `'path/to/entitlements'` |
159+
| `hardenedRuntime` | Boolean flag to enable the Hardened Runtime when signing the app. Enabled by default. | `false` |
160+
| `requirements` | String specifying the [requirements](https://developer.apple.com/library/mac/documentation/Security/Conceptual/CodeSigningGuide/RequirementLang/RequirementLang.html) that you recommend to be used to evaluate the code signature. | `'anchor apple or anchor = "/var/db/yourcorporateanchor.cert"'` |
161+
| `signatureFlags` | List of [code signature flags](https://developer.apple.com/documentation/security/seccodesignatureflags?language=objc). Accepts an array of strings or a comma-separated string. | `['kSecCodeSignatureRestrict']` |
162+
| `timestamp` | String specifying the URL of the timestamp authority server. Defaults to the server provided by Apple. Please note that this default server may not support signatures not furnished by Apple. Disable the timestamp service with `none`. | `'https://different.timeserver'` |
173163

174164
**Note:** Only available via the JS API
175165

176-
`gatekeeper-assess` - *Boolean*
177-
178-
Flag to enable/disable Gatekeeper assessment after signing the app. Disabling it is useful for signing with self-signed certificates.
179-
Gatekeeper assessment is enabled by default on `darwin` platform.
180-
Default to `true`.
181-
182166
`hardenedRuntime` or `hardened-runtime` - *Boolean*
183167

184168
Flag to enable the Mojave hardened runtime when signing the app. Disabled by default, requires Xcode >= 10 and
@@ -191,7 +175,7 @@ Default to be selected with respect to `provisioning-profile` and `platform` fro
191175

192176
Signing platform `mas` will look for `3rd Party Mac Developer Application: * (*)`, and platform `darwin` will look for `Developer ID Application: * (*)` by default.
193177

194-
`identity-validation` - *Boolean*
178+
`identityValidation` - *Boolean*
195179

196180
Flag to enable/disable validation for the signing identity. If enabled, the `identity` provided will be validated in the `keychain` specified.
197181
Default to `true`.
@@ -213,49 +197,27 @@ Build platform of Electron.
213197
Allowed values: `darwin`, `mas`.
214198
Default to auto detect by presence of `Squirrel.framework` within the application bundle.
215199

216-
`pre-auto-entitlements` - *Boolean*
200+
`preAutoEntitlements` - *Boolean*
217201

218202
Flag to enable/disable automation of `com.apple.security.application-groups` in entitlements file and update `Info.plist` with `ElectronTeamID`.
219203
Default to `true`.
220204

221-
`pre-embed-provisioning-profile` - *Boolean*
205+
`preEmbedProvisioningProfile` - *Boolean*
222206

223207
Flag to enable/disable embedding of provisioning profile in the current working directory.
224208
Default to `true`.
225209

226-
`provisioning-profile` - *String*
210+
`provisioningProfile` - *String*
227211

228212
Path to provisioning profile.
229213

230-
`requirements` - *String*
231-
232-
Specify the criteria that you recommend to be used to evaluate the code signature.
233-
See more info from https://developer.apple.com/library/mac/documentation/Security/Conceptual/CodeSigningGuide/RequirementLang/RequirementLang.html
234-
Default to `undefined`.
235-
236-
`restrict` - *Boolean*
237-
238-
**To be deprecated, see `signature-flags`.**
239-
Restrict dyld loading. See doc about this [code signature flag](https://developer.apple.com/documentation/security/seccodesignatureflags/kseccodesignaturerestrict?language=objc) for more details. Disabled by default.
240-
241-
`signature-flags` - *String*
242-
Comma separated string or array for [code signature flag](https://developer.apple.com/documentation/security/seccodesignatureflags?language=objc). Default to `undefined`.
243-
244-
`signature-size` - *Number*
245-
Provide a value to be passed to `codesign` along with the `--signature-size` flag, to work around the *signature too large to embed* issue. A value of `12000` should do it - see the [FAQ](https://github.com/electron/electron-osx-sign/wiki/FAQ) for details. Default to `undefined`.
246-
247-
`strict-verify` - *Boolean|String|Array.<String>*
214+
`strictVerify` - *Boolean|String|Array.<String>*
248215

249216
Flag to enable/disable `--strict` flag when verifying the signed application bundle.
250217
If provided as a string, each component should be separated with comma (`,`).
251218
If provided as an array, each item should be a string corresponding to a component.
252219
Default to `true`.
253220

254-
`timestamp` - *String*
255-
256-
Specify the URL of the timestamp authority server, default to server provided by Apple. Please note that this default server may not support signatures not furnished by Apple.
257-
Disable the timestamp service with `none`.
258-
259221
`type` - *String*
260222

261223
Specify whether to sign app for development or for distribution.
@@ -354,7 +316,7 @@ Default to be selected with respect to `platform` from `keychain` or keychain by
354316

355317
Flattening platform `mas` will look for `3rd Party Mac Developer Installer: * (*)`, and platform `darwin` will look for `Developer ID Installer: * (*)` by default.
356318

357-
`identity-validation` - *Boolean*
319+
`identityValidation` - *Boolean*
358320

359321
Flag to enable/disable validation for signing identity. If enabled, the `identity` provided will be validated in the `keychain` specified.
360322
Default to `true`.

bin/electron-osx-flat-usage.txt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ DESCRIPTION
1717
Name of certificate to use when signing.
1818
Default to selected with respect to --platform from --keychain specified or keychain by system default.
1919

20-
--identity-validation, --no-identity-validation
20+
--identityValidation, --no-identityValidation
2121
Flag to enable/disable validation for the signing identity.
2222

2323
--install=install-path

bin/electron-osx-sign-usage.txt

Lines changed: 2 additions & 39 deletions
Original file line numberDiff line numberDiff line change
@@ -13,34 +13,14 @@ DESCRIPTION
1313
embedded-binary ...
1414
Path to additional binaries that will be signed along with built-ins of Electron, spaced.
1515

16-
--entitlements=file
17-
Path to entitlements file for signing the app.
18-
Default to built-in entitlements file, Sandbox enabled for Mac App Store platform.
19-
20-
--entitlements-inherit=file
21-
Path to child entitlements which inherit the security settings for signing frameworks and bundles of a distribution.
22-
This option only applies when signing with entitlements.
23-
24-
--entitlements-loginhelper=file
25-
Path to login helper entitlement file. When using App Sandbox, the inherited entitlement should not be used since this is a standalone executable.
26-
This option only applies when signing with entitlements.
27-
28-
--gatekeeper-assess, --no-gatekeeper-assess
29-
Flag to enable/disable Gatekeeper assessment after signing the app. Disabling it is useful for signing with self-signed certificates.
30-
Gatekeeper assessment is enabled by default on ``darwin'' platform.
31-
32-
--hardened-runtime
33-
Flag to enable the Mojave hardened runtime when signing the app. Disabled by default, requires Xcode >= 10 and macOS
34-
>= 10.13.6.
35-
3616
--help
3717
Flag to display all commands.
3818

3919
--identity=identity
4020
Name of certificate to use when signing.
4121
Default to selected with respect to --provisioning-profile and --platform from --keychain specified or keychain by system default.
4222

43-
--identity-validation, --no-identity-validation
23+
--identityValidation, --no-identityValidation
4424
Flag to enable/disable validation for the signing identity.
4525

4626
--ignore=path
@@ -64,28 +44,11 @@ DESCRIPTION
6444
--provisioning-profile=file
6545
Path to provisioning profile.
6646

67-
--requirements=requirements
68-
Specify the criteria that you recommend to be used to evaluate the code signature.
69-
70-
--restrict
71-
(This will be deprecated soon, see --sign-flags.)
72-
Flag to enable restrict mode. Disabled by default.
73-
74-
--signature-flags=flags
75-
Code signature flags. Default to none.
76-
77-
--signature-size=size
78-
Signature size. Default to none.
79-
80-
--strict-verify, --strict-verify=options, --no-strict-verify
47+
--strictVerify, --strictVerify=options, --no-strictVerify
8148
Flag to enable/disable ``--strict'' flag when verifying the signed application bundle.
8249
Each component should be separated in ``options'' with comma (``,'').
8350
Enabled by default.
8451

85-
--timestamp=timestamp
86-
Specify the URL of the timestamp authority server, default to server provided by Apple.
87-
Disable the timestamp service with ``none''.
88-
8952
--type=type
9053
Specify whether to sign app for development or for distribution.
9154
Allowed values: ``development'', ``distribution''.

bin/electron-osx-sign.js

Lines changed: 1 addition & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -6,21 +6,16 @@ const args = require('minimist')(process.argv.slice(2), {
66
string: [
77
'signature-flags'
88
],
9-
number: [
10-
'signature-size'
11-
],
129
boolean: [
1310
'help',
1411
'pre-auto-entitlements',
1512
'pre-embed-provisioning-profile',
16-
'gatekeeper-assess',
1713
'hardened-runtime',
1814
'restrict'
1915
],
2016
default: {
2117
'pre-auto-entitlements': true,
22-
'pre-embed-provisioning-profile': true,
23-
'gatekeeper-assess': true
18+
'pre-embed-provisioning-profile': true
2419
}
2520
});
2621
const usage = fs.readFileSync(path.join(__dirname, 'electron-osx-sign-usage.txt')).toString();

entitlements/default.entitlements.mas.plist renamed to entitlements/default.darwin.gpu.plist

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
33
<plist version="1.0">
44
<dict>
5-
<key>com.apple.security.app-sandbox</key>
5+
<key>com.apple.security.cs.allow-jit</key>
66
<true/>
77
</dict>
88
</plist>

entitlements/default.darwin.plist

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
<?xml version="1.0" encoding="UTF-8"?>
2+
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
3+
<plist version="1.0">
4+
<dict>
5+
<key>com.apple.security.cs.allow-jit</key>
6+
<true/>
7+
<key>com.apple.security.device.audio-input</key>
8+
<true/>
9+
<key>com.apple.security.device.bluetooth</key>
10+
<true/>
11+
<key>com.apple.security.device.camera</key>
12+
<true/>
13+
<key>com.apple.security.device.print</key>
14+
<true/>
15+
<key>com.apple.security.device.usb</key>
16+
<true/>
17+
<key>com.apple.security.personal-information.location</key>
18+
<true/>
19+
</dict>
20+
</plist>

entitlements/default.entitlements.darwin.plist renamed to entitlements/default.darwin.plugin.plist

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,5 +2,9 @@
22
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
33
<plist version="1.0">
44
<dict>
5+
<key>com.apple.security.cs.allow-unsigned-executable-memory</key>
6+
<true/>
7+
<key>com.apple.security.cs.disable-library-validation</key>
8+
<true/>
59
</dict>
610
</plist>

entitlements/default.entitlements.darwin.inherit.plist renamed to entitlements/default.darwin.renderer.plist

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,5 +2,7 @@
22
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
33
<plist version="1.0">
44
<dict>
5+
<key>com.apple.security.cs.allow-jit</key>
6+
<true/>
57
</dict>
68
</plist>
File renamed without changes.

0 commit comments

Comments
 (0)