Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat(cli): add macos hardened runtime signing config option #9318

Open
wants to merge 6 commits into
base: dev
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
8 changes: 8 additions & 0 deletions .changes/hardened-runtime-option.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
---
"tauri-bundler": patch:feat
"@tauri-apps/cli": patch:feat
"tauri-cli": patch:feat
"tauri-utils": patch:feat
---

Added a configuration option to disable hardened runtime on macOS codesign.
7 changes: 7 additions & 0 deletions core/tauri-config-schema/schema.json
Original file line number Diff line number Diff line change
Expand Up @@ -104,6 +104,7 @@
}
},
"files": {},
"hardenedRuntime": true,
"minimumSystemVersion": "10.13"
},
"targets": "all",
Expand Down Expand Up @@ -1676,6 +1677,7 @@
}
},
"files": {},
"hardenedRuntime": true,
"minimumSystemVersion": "10.13"
},
"allOf": [
Expand Down Expand Up @@ -2681,6 +2683,11 @@
"null"
]
},
"hardenedRuntime": {
"description": "Whether the codesign should enable [hardened runtime] (for executables) or not.\n\n[hardened runtime]: <https://developer.apple.com/documentation/security/hardened_runtime>",
"default": true,
"type": "boolean"
},
"providerShortName": {
"description": "Provider short name for notarization.",
"type": [
Expand Down
10 changes: 10 additions & 0 deletions core/tauri-utils/src/config.rs
Original file line number Diff line number Diff line change
Expand Up @@ -565,6 +565,11 @@ pub struct MacConfig {
/// Identity to use for code signing.
#[serde(alias = "signing-identity")]
pub signing_identity: Option<String>,
/// Whether the codesign should enable [hardened runtime] (for executables) or not.
///
/// [hardened runtime]: <https://developer.apple.com/documentation/security/hardened_runtime>
#[serde(alias = "hardened-runtime", default = "hardened_runtime")]
pub hardened_runtime: bool,
/// Provider short name for notarization.
#[serde(alias = "provider-short-name")]
pub provider_short_name: Option<String>,
Expand All @@ -575,6 +580,10 @@ pub struct MacConfig {
pub dmg: DmgConfig,
}

fn hardened_runtime() -> bool {
true
}

impl Default for MacConfig {
fn default() -> Self {
Self {
Expand All @@ -583,6 +592,7 @@ impl Default for MacConfig {
minimum_system_version: minimum_system_version(),
exception_domain: None,
signing_identity: None,
hardened_runtime: hardened_runtime(),
provider_short_name: None,
entitlements: None,
dmg: Default::default(),
Expand Down
4 changes: 3 additions & 1 deletion tooling/bundler/src/bundle/macos/sign.rs
Original file line number Diff line number Diff line change
Expand Up @@ -205,7 +205,9 @@ fn try_sign(
args.push(entitlements_path);
}

if is_an_executable {
// add runtime flag by default

if is_an_executable && settings.macos().hardened_runtime {
args.push("--options");
args.push("runtime");
}
Expand Down
4 changes: 4 additions & 0 deletions tooling/bundler/src/bundle/settings.rs
Original file line number Diff line number Diff line change
Expand Up @@ -317,6 +317,10 @@ pub struct MacOsSettings {
pub exception_domain: Option<String>,
/// Code signing identity.
pub signing_identity: Option<String>,
/// Preserve the hardened runtime version flag, see <https://developer.apple.com/documentation/security/hardened_runtime>
///
/// Settings this to `false` is useful when using an ad-hoc signature, making it less strict.
pub hardened_runtime: bool,
/// Provider short name for notarization.
pub provider_short_name: Option<String>,
/// Path to the entitlements.plist file.
Expand Down
7 changes: 7 additions & 0 deletions tooling/cli/schema.json
Original file line number Diff line number Diff line change
Expand Up @@ -104,6 +104,7 @@
}
},
"files": {},
"hardenedRuntime": true,
"minimumSystemVersion": "10.13"
},
"targets": "all",
Expand Down Expand Up @@ -1676,6 +1677,7 @@
}
},
"files": {},
"hardenedRuntime": true,
"minimumSystemVersion": "10.13"
},
"allOf": [
Expand Down Expand Up @@ -2681,6 +2683,11 @@
"null"
]
},
"hardenedRuntime": {
"description": "Whether the codesign should enable [hardened runtime] (for executables) or not.\n\n[hardened runtime]: <https://developer.apple.com/documentation/security/hardened_runtime>",
"default": true,
"type": "boolean"
},
"providerShortName": {
"description": "Provider short name for notarization.",
"type": [
Expand Down
1 change: 1 addition & 0 deletions tooling/cli/src/interface/rust.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1361,6 +1361,7 @@ fn tauri_config_to_bundle_settings(
minimum_system_version: config.macos.minimum_system_version,
exception_domain: config.macos.exception_domain,
signing_identity,
hardened_runtime: config.macos.hardened_runtime,
provider_short_name,
entitlements: config.macos.entitlements,
info_plist_path: {
Expand Down