Skip to content

Commit 656a649

Browse files
feat(cli): add macos hardened runtime signing config option (#9318)
* feat(cli): add macos signing config option * rename option to hardened_runtime * chore(cli): use default true in hardened runtime config --------- Co-authored-by: Lucas Nogueira <lucas@tauri.app>
1 parent f29b788 commit 656a649

File tree

7 files changed

+36
-1
lines changed

7 files changed

+36
-1
lines changed
Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
---
2+
"tauri-bundler": patch:feat
3+
"@tauri-apps/cli": patch:feat
4+
"tauri-cli": patch:feat
5+
"tauri-utils": patch:feat
6+
---
7+
8+
Added a configuration option to disable hardened runtime on macOS codesign.

core/tauri-config-schema/schema.json

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -104,6 +104,7 @@
104104
}
105105
},
106106
"files": {},
107+
"hardenedRuntime": true,
107108
"minimumSystemVersion": "10.13"
108109
},
109110
"targets": "all",
@@ -1683,6 +1684,7 @@
16831684
}
16841685
},
16851686
"files": {},
1687+
"hardenedRuntime": true,
16861688
"minimumSystemVersion": "10.13"
16871689
},
16881690
"allOf": [
@@ -2688,6 +2690,11 @@
26882690
"null"
26892691
]
26902692
},
2693+
"hardenedRuntime": {
2694+
"description": "Whether the codesign should enable [hardened runtime] (for executables) or not.\n\n[hardened runtime]: <https://developer.apple.com/documentation/security/hardened_runtime>",
2695+
"default": true,
2696+
"type": "boolean"
2697+
},
26912698
"providerShortName": {
26922699
"description": "Provider short name for notarization.",
26932700
"type": [

core/tauri-utils/src/config.rs

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -565,6 +565,11 @@ pub struct MacConfig {
565565
/// Identity to use for code signing.
566566
#[serde(alias = "signing-identity")]
567567
pub signing_identity: Option<String>,
568+
/// Whether the codesign should enable [hardened runtime] (for executables) or not.
569+
///
570+
/// [hardened runtime]: <https://developer.apple.com/documentation/security/hardened_runtime>
571+
#[serde(alias = "hardened-runtime", default = "default_true")]
572+
pub hardened_runtime: bool,
568573
/// Provider short name for notarization.
569574
#[serde(alias = "provider-short-name")]
570575
pub provider_short_name: Option<String>,
@@ -583,6 +588,7 @@ impl Default for MacConfig {
583588
minimum_system_version: minimum_system_version(),
584589
exception_domain: None,
585590
signing_identity: None,
591+
hardened_runtime: true,
586592
provider_short_name: None,
587593
entitlements: None,
588594
dmg: Default::default(),

tooling/bundler/src/bundle/macos/sign.rs

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -205,7 +205,9 @@ fn try_sign(
205205
args.push(entitlements_path);
206206
}
207207

208-
if is_an_executable {
208+
// add runtime flag by default
209+
210+
if is_an_executable && settings.macos().hardened_runtime {
209211
args.push("--options");
210212
args.push("runtime");
211213
}

tooling/bundler/src/bundle/settings.rs

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -317,6 +317,10 @@ pub struct MacOsSettings {
317317
pub exception_domain: Option<String>,
318318
/// Code signing identity.
319319
pub signing_identity: Option<String>,
320+
/// Preserve the hardened runtime version flag, see <https://developer.apple.com/documentation/security/hardened_runtime>
321+
///
322+
/// Settings this to `false` is useful when using an ad-hoc signature, making it less strict.
323+
pub hardened_runtime: bool,
320324
/// Provider short name for notarization.
321325
pub provider_short_name: Option<String>,
322326
/// Path to the entitlements.plist file.

tooling/cli/schema.json

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -104,6 +104,7 @@
104104
}
105105
},
106106
"files": {},
107+
"hardenedRuntime": true,
107108
"minimumSystemVersion": "10.13"
108109
},
109110
"targets": "all",
@@ -1683,6 +1684,7 @@
16831684
}
16841685
},
16851686
"files": {},
1687+
"hardenedRuntime": true,
16861688
"minimumSystemVersion": "10.13"
16871689
},
16881690
"allOf": [
@@ -2688,6 +2690,11 @@
26882690
"null"
26892691
]
26902692
},
2693+
"hardenedRuntime": {
2694+
"description": "Whether the codesign should enable [hardened runtime] (for executables) or not.\n\n[hardened runtime]: <https://developer.apple.com/documentation/security/hardened_runtime>",
2695+
"default": true,
2696+
"type": "boolean"
2697+
},
26912698
"providerShortName": {
26922699
"description": "Provider short name for notarization.",
26932700
"type": [

tooling/cli/src/interface/rust.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1362,6 +1362,7 @@ fn tauri_config_to_bundle_settings(
13621362
minimum_system_version: config.macos.minimum_system_version,
13631363
exception_domain: config.macos.exception_domain,
13641364
signing_identity,
1365+
hardened_runtime: config.macos.hardened_runtime,
13651366
provider_short_name,
13661367
entitlements: config.macos.entitlements,
13671368
info_plist_path: {

0 commit comments

Comments
 (0)