Skip to content

Commit f2e4353

Browse files
authored
Fix macos signing/notarization (#5527)
* Staple notarization to .app not .zip * Fix default value for hardened_runtime macos bundle setting
1 parent a626d60 commit f2e4353

2 files changed

Lines changed: 28 additions & 8 deletions

File tree

packages/cli/src/bundler/macos.rs

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -221,7 +221,7 @@ impl BundleContext<'_> {
221221
bail!("ditto failed to create zip for notarization");
222222
}
223223

224-
match notarize(&zip_path).await {
224+
match notarize(&zip_path, &app_dir).await {
225225
Ok(()) => {
226226
let _ = fs::remove_file(&zip_path);
227227
}
@@ -356,7 +356,7 @@ impl BundleContext<'_> {
356356
std::env::var("APPLE_ID").is_ok() || std::env::var("APPLE_API_KEY").is_ok();
357357

358358
if should_notarize {
359-
notarize(&dmg_path).await?;
359+
notarize(&dmg_path, &dmg_path).await?;
360360
}
361361
}
362362

@@ -853,7 +853,7 @@ async fn sign_path(
853853
}
854854

855855
/// Notarize a .app or .dmg with Apple's notary service.
856-
async fn notarize(app_path: &Path) -> Result<()> {
856+
async fn notarize(notarize_path: &Path, staple_path: &Path) -> Result<()> {
857857
let apple_id = std::env::var("APPLE_ID").ok();
858858
let apple_password = std::env::var("APPLE_PASSWORD").ok();
859859
let apple_team_id = std::env::var("APPLE_TEAM_ID").ok();
@@ -863,7 +863,7 @@ async fn notarize(app_path: &Path) -> Result<()> {
863863

864864
let mut cmd = Command::new("xcrun");
865865
cmd.args(["notarytool", "submit"]);
866-
cmd.arg(app_path);
866+
cmd.arg(notarize_path);
867867

868868
if let (Some(key), Some(issuer), Some(key_path)) = (&api_key, &api_issuer, &api_key_path) {
869869
cmd.args(["--key", key_path]);
@@ -883,15 +883,15 @@ async fn notarize(app_path: &Path) -> Result<()> {
883883

884884
cmd.arg("--wait");
885885

886-
tracing::info!("Submitting {} for notarization...", app_path.display());
886+
tracing::info!("Submitting {} for notarization...", notarize_path.display());
887887
run_command(&mut cmd, "xcrun notarytool submit").await?;
888888

889889
tracing::info!("Stapling notarization ticket...");
890890
let mut staple_cmd = Command::new("xcrun");
891-
staple_cmd.args(["stapler", "staple"]).arg(app_path);
891+
staple_cmd.args(["stapler", "staple"]).arg(staple_path);
892892
run_command(&mut staple_cmd, "xcrun stapler staple").await?;
893893

894-
tracing::info!("Notarization complete for {}", app_path.display());
894+
tracing::info!("Notarization complete for {}", staple_path.display());
895895
Ok(())
896896
}
897897

packages/cli/src/config/bundle.rs

Lines changed: 21 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -149,7 +149,7 @@ pub(crate) struct WixSettings {
149149
pub upgrade_code: Option<uuid::Uuid>,
150150
}
151151

152-
#[derive(Debug, Clone, Serialize, Deserialize, Default, JsonSchema)]
152+
#[derive(Debug, Clone, Serialize, Deserialize, JsonSchema)]
153153
pub(crate) struct MacOsSettings {
154154
#[serde(default)]
155155
pub(crate) bundle_version: Option<String>,
@@ -197,6 +197,26 @@ fn default_hardened_runtime() -> bool {
197197
true
198198
}
199199

200+
// Custom default impl so that we can default hardened_runtime to true
201+
impl Default for MacOsSettings {
202+
fn default() -> Self {
203+
Self {
204+
bundle_version: None,
205+
frameworks: None,
206+
minimum_system_version: None,
207+
license: None,
208+
exception_domain: None,
209+
signing_identity: None,
210+
provider_short_name: None,
211+
entitlements: None,
212+
info_plist_path: None,
213+
bundle_name: None,
214+
files: HashMap::new(),
215+
hardened_runtime: true,
216+
}
217+
}
218+
}
219+
200220
#[derive(Debug, Clone, Serialize, Deserialize, Default, JsonSchema)]
201221
pub(crate) struct WindowsSettings {
202222
#[serde(default)]

0 commit comments

Comments
 (0)