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

MacOS codesigning does not enable hardened runtime options #1534

Open
jamesmunns opened this issue Nov 7, 2024 · 2 comments
Open

MacOS codesigning does not enable hardened runtime options #1534

jamesmunns opened this issue Nov 7, 2024 · 2 comments

Comments

@jamesmunns
Copy link

Hey there, I'm working my way through figuring out how to get a signed + notarized app built by cargo-dist. I've followed the instructions in #1372, which do produced a signed application, however when I attempted to notarize my executable, I get the following error:

  "issues": [
    {
      "severity": "error",
      "code": null,
      "path": "poststation-v0_0_11.zip/poststation",
      "message": "The executable does not have the hardened runtime enabled.",
      "docUrl": "https://developer.apple.com/documentation/security/notarizing_macos_software_before_distribution/resolving_common_notarization_issues#3087724",
      "architecture": "arm64"
    }
  ]

The signing step for macos:

pub fn sign(&self, file: &Utf8Path) -> DistResult<()> {
let password = uuid::Uuid::new_v4().as_hyphenated().to_string();
let keychain = Keychain::create(password)?;
keychain.import_certificate(&self.env.certificate, &self.env.password)?;
let mut cmd = Cmd::new("/usr/bin/codesign", "sign macOS artifacts");
cmd.arg("--sign").arg(&self.env.identity);
cmd.arg("--keychain").arg(&keychain.path);
cmd.arg(file);
cmd.stdout_to_stderr();
cmd.output()?;
Ok(())
}

Doesn't set the following flags: [--force] --options runtime.

The apple docs mention the --options runtime argument:

I'm unsure if --force is required here, but I've seen it mentioned in a couple places:

At the moment, I haven't enabled the creation of a pkg or dmg, so i'm just building a bare application that I put in a zip for notarization.

I'll keep trying to do this locally, and see if I can find the right combination required to get signing and notarized. Happy to test out anything here re: macos signing!

@jamesmunns
Copy link
Author

Additionally, to get things to work, I seem to have also needed to add:

--timestamp --entitlements ./entitlements.plist. Right now I don't need any entitlements, so my contents are:

<?xml version="1.0" encoding="UTF-8" ?>
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
</dict>
</plist>

@mistydemeo
Copy link
Contributor

I'll take a look into it thank you!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants