-
Notifications
You must be signed in to change notification settings - Fork 4
Notes about apple code signing for developers #72
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
directionless
wants to merge
2
commits into
osquery:main
Choose a base branch
from
directionless:seph/applesign
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 1 commit
Commits
Show all changes
2 commits
Select commit
Hold shift + click to select a range
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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,127 @@ | ||
| # Codesigning for Apple Developers | ||
|
|
||
| With the introduction of Apple's EndpointSecurity framework ([PR | ||
| 6467](https://github.com/osquery/osquery/pull/6467), we've started to | ||
| need entitlements, profiles, and codesigning. Even in development. | ||
|
|
||
| As I understand Apple's model: | ||
| 1. apps/packages/etc are signed by certs. | ||
| 2. There are _many_ different flavors of certificate. For our | ||
| purposes, the ones that matter: | ||
| - Developer ID Installer: Privileged. Allows installer distribution | ||
| outside the app store. | ||
| - Developer ID Application: Privileged. Allows app distribution | ||
| outside the app store. | ||
| - Apple Development / Mac Development: Developer. Allows signing | ||
| development versions. | ||
| 3. The privileged ones, coupled with an entitlements file allow | ||
| osquery to work. | ||
| 4. The developer ones _also_ require a profile, which only works on | ||
| macs identified by uuid. | ||
| - `select uuid from system_info` | ||
| 5. Apple accounts can have members that are `developers`. These | ||
| members can create personal developer certificates, but cannot | ||
| create distribution ones. Cannot adjust devices. Cannot adjust | ||
| profiles. According, it should be pretty reasonable to add osquery | ||
| developers to the account. | ||
|
|
||
| ## Process for adding a new developer | ||
|
|
||
| _*Note*: This is for adding a new developer to the account. This | ||
| should not grant distribution permission, but they should still be somewhat trusted._ | ||
|
|
||
| Create a foundation ticket for general tracking and details. If any of | ||
| this is considered private, consider using slack to communicate | ||
| details. | ||
|
|
||
| We will need the email address for their apple account. They can | ||
| create a new one, or use an existing one. This should be a | ||
| human. Apple does not like roll accounts. | ||
directionless marked this conversation as resolved.
Outdated
Show resolved
Hide resolved
|
||
|
|
||
| We need their test machine[s] uuid. This can be gathered with `select | ||
| uuid from system_info;` | ||
|
|
||
| ### Admin Actions | ||
|
|
||
| Login to https://developer.apple.com/ | ||
|
|
||
| Under `Certificates, Identifiers & Profiles` find `Devices`. Add their | ||
| uuid. Name the device something reasonable. | ||
|
|
||
| Find the people tab, it will take you to App Store Connect | ||
|
|
||
| Add them as a `Developer` Check the box to allow access to | ||
| certificates. | ||
|
|
||
| ### Developer Actions | ||
|
|
||
| Xcode might be able to do this for you. These are manual instructions. | ||
|
|
||
| Use `Certificate Assistant`: | ||
| 1. Open `Keychain Access` | ||
| 2. `Keychain Access` menu -> `Certificate Assistent` -> `Request a Certificate from a CA` | ||
| 3. Use your apple id email address (might not matter) | ||
| 4. Maybe sure it's saved to disk | ||
| 5. Save the CSR somewhere | ||
|
|
||
| Login to https://developer.apple.com/ | ||
|
|
||
| You should have access to the osquery account, `3522FA9PXF`. If you | ||
| have multiple accounts, it will be in the top right pulldown. | ||
|
|
||
| Click `Certificates, Identifiers & Profiles` and create a certificate. | ||
|
|
||
| You'll want either an `Apple Development` or a `Mac Development` | ||
| certificate. | ||
|
|
||
| Upload the CSR generated earlier. | ||
|
|
||
| You should now be able to download the certificate. | ||
|
|
||
| ### Back to the Admin | ||
|
|
||
| Now the admin will have to add the developer and the device to the | ||
| profile. Or create one specific to this developer. Probably doesn't | ||
| matter much. | ||
|
|
||
| ### Back to the developer | ||
|
|
||
| Finally, you can download a profile. This needs to be installed on the | ||
| machines to allow the machine to trust the code signing. | ||
|
|
||
| ## How to Use Endpoint Security | ||
|
|
||
| _*NOTE*: you need to be building on catalina or later_ | ||
|
|
||
| Build something. This is using some demo esf code: | ||
|
|
||
| Cannot run without any signatures: | ||
|
|
||
| ``` shell | ||
| $ ./endpointsecurity | ||
| client lacks entitlement | ||
| ``` | ||
|
|
||
|
|
||
| Code sign without entitlements | ||
|
|
||
| ``` shell | ||
| $ codesign --force -s "${CODESIGN_IDENTITY}" -v --options runtime,library --timestamp ./endpointsecurity | ||
|
|
||
| $ ./endpointsecurity | ||
| client lacks entitlement | ||
| ``` | ||
|
|
||
| Finally, with entitlements. | ||
|
|
||
| ``` shell | ||
| $ codesign --force -s "${CODESIGN_IDENTITY}" -v --options runtime,library --timestamp --entitlements endpointsecurity.entitlements ./endpointsecurity | ||
|
|
||
| $ ./endpointsecurity.entitled | ||
| Killed: 9 | ||
| ``` | ||
|
|
||
|
|
||
| Oh no! We still need to install the profile authorizing this host. | ||
|
|
||
| Still `killed: 9` | ||
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.
I think you mean
rolehereThere 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 don't know what Apple likes or doesn't like, but FWIW, at the Trail of Bits team we have an account / "person" called Continuous Integration, which signs in CI for testing (has its own Development certificate, is added to the Development provisioning profile).