-
Notifications
You must be signed in to change notification settings - Fork 110
docs: WIP Mac codesigning docs #1372
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
Draft
mistydemeo
wants to merge
1
commit into
main
Choose a base branch
from
mac-codesign-docs
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Draft
Changes from all commits
Commits
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 | ||||||
- `CODESIGN_CERTIFICATE_PASSWORD`: this is the base64-encoded certificate from Step 4 | ||||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Should this be There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Suggested change
|
||||||
- `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. |
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
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)
?There was a problem hiding this comment.
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!
There was a problem hiding this comment.
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!
There was a problem hiding this comment.
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.