Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions book/src/SUMMARY.md
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@
- [Custom Builds](./custom-builds.md)
- [Supplychain Security](./supplychain-security/index.md)
- [Windows Signing](./supplychain-security/signing/windows.md)
- [macOS Signing](./supplychain-security/signing/macos.md)
- [GitHub Attestations](./supplychain-security/attestations/github.md)
- [Installers](./installers/index.md)
- [shell](./installers/shell.md)
Expand Down
1 change: 1 addition & 0 deletions book/src/reference/config.md
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@ We're currently in the middle of [a major config migration](https://github.com/a
* [`extra-artifacts`](#extra-artifacts)
* [`source-tarball`](#source-tarball)
* [`ssldotcom-windows-sign`](#ssldotcom-windows-sign)
* [`macos-sign`](#macos-sign)
* [archive settings](#artifact-settings)
* [`auto-includes`](#auto-includes)
* [`include`](#include)
Expand Down
2 changes: 1 addition & 1 deletion book/src/supplychain-security/index.md
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ If you have an integration you are looking for [file an issue](https://github.co
## Signing

* [Windows Codesigning](./signing/windows.md)
* [🔜 macOS Codesigning](https://github.com/axodotdev/cargo-dist/issues/1121)
* [macOS Codesigning](./signing/macos.md)
* [🔜 Linux Codesigning](https://github.com/axodotdev/cargo-dist/issues/120)
* [🔜 Sigstore Signing](https://github.com/axodotdev/cargo-dist/issues/120)
* [🔜 Windows Trusted Signing](https://github.com/axodotdev/cargo-dist/issues/1122)
Expand Down
50 changes: 50 additions & 0 deletions book/src/supplychain-security/signing/macos.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,50 @@
# MacOS Artifact Signing

> since 0.22.0

cargo-dist can automatically codesign Mac executables using Apple's builtin tooling.

## Quickstart

### Part 1: Provision a certificate and set up your repository with it

<!-- TODO: Document the process of obtaining and exporting the signature. -->

3. **Export the certificate to disk**

Locate your certificate within Keychain, then right-click and select "Export". Ensure that you've selected the "Personal Information Exchange (.p12)" format at the bottom of the export window. Once you've selected a filename, Keychain will prompt you for a password to protect the exported item. Select a secure password, *and ensure remember it* - you'll need this for the next step.

4. **Encode the certificate via base64**

In order to add the certificate to your GitHub secrets in a future step, we'll need to convert it to a text-based format. To do that, we'll use base64. In your terminal, run the following:

```sh
base64 < PATH_TO_YOUR_CERT
```

(Instead of typing the path to your certificate, you can also drag and drop it onto your terminal after typing `base64 <`.)

Copy *the full text* that was generated; you'll need it in the next step.

5. **Add [GitHub Secrets](https://docs.github.com/en/actions/security-guides/encrypted-secrets) to your repository**

You'll need the following three secrets:

- `CODESIGN_IDENTITY`: the identity in the certificate

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Should this be the "User ID" from the certificate? e.g. the part of the name at the end like (XXXXXXXXXX)?

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes - this seems to work!

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'll update the docs to make that clearer!

Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Note: you can find that ID also with security find-identity -v -p codesigning from the terminal.

- `CODESIGN_CERTIFICATE_PASSWORD`: this is the base64-encoded certificate from Step 4
Copy link

@jamesmunns jamesmunns Nov 6, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Should this be CODESIGN_CERTIFICATE? (edit: yes!)

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
- `CODESIGN_CERTIFICATE_PASSWORD`: this is the base64-encoded certificate from Step 4
- `CODESIGN_CERTIFICATE`: this is the base64-encoded certificate from Step 4

- `CODESIGN_CERTIFICATE_PASSWORD`: this is the password from Step 3

### Part 2: Enable macOS signing with cargo-dist

1. **Configure cargo-dist to codesign**

Add the following to your `Cargo.toml` or `dist.toml`:

```toml
[workspace.metadata.dist]
macos-sign = true
```

2. **Run `cargo dist init` on your project**

You've already fully configured the feature, we're just ensuring your config changes are applied and checked.
Loading