Skip to content

Commit fe3b4b6

Browse files
committed
Notes about apple code signging for developers
1 parent 75c5ecd commit fe3b4b6

File tree

1 file changed

+127
-0
lines changed

1 file changed

+127
-0
lines changed
Lines changed: 127 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,127 @@
1+
# Codesigning for Apple Developers
2+
3+
With the introduction of Apple's EndpointSecurity framework ([PR
4+
6467](https://github.com/osquery/osquery/pull/6467), we've started to
5+
need entitlements, profiles, and codesigning. Even in development.
6+
7+
As I understand Apple's model:
8+
1. apps/packages/etc are signed by certs.
9+
2. There are _many_ different flavors of certificate. For our
10+
purposes, the ones that matter:
11+
- Developer ID Installer: Privileged. Allows installer distribution
12+
outside the app store.
13+
- Developer ID Application: Privileged. Allows app distribution
14+
outside the app store.
15+
- Apple Development / Mac Development: Developer. Allows signing
16+
development versions.
17+
3. The privileged ones, coupled with an entitlements file allow
18+
osquery to work.
19+
4. The developer ones _also_ require a profile, which only works on
20+
macs identified by uuid.
21+
- `select uuid from system_info`
22+
5. Apple accounts can have members that are `developers`. These
23+
members can create personal developer certificates, but cannot
24+
create distribution ones. Cannot adjust devices. Cannot adjust
25+
profiles. According, it should be pretty reasonable to add osquery
26+
developers to the account.
27+
28+
## Process for adding a new developer
29+
30+
_*Note*: This is for adding a new developer to the account. This
31+
should not grant distribution permission, but they should still be somewhat trusted._
32+
33+
Create a foundation ticket for general tracking and details. If any of
34+
this is considered private, consider using slack to communicate
35+
details.
36+
37+
We will need the email address for their apple account. They can
38+
create a new one, or use an existing one. This should be a
39+
human. Apple does not like roll accounts.
40+
41+
We need their test machine[s] uuid. This can be gathered with `select
42+
uuid from system_info;`
43+
44+
### Admin Actions
45+
46+
Login to https://developer.apple.com/
47+
48+
Under `Certificates, Identifiers & Profiles` find `Devices`. Add their
49+
uuid. Name the device something reasonable.
50+
51+
Find the people tab, it will take you to App Store Connect
52+
53+
Add them as a `Developer` Check the box to allow access to
54+
certificates.
55+
56+
### Developer Actions
57+
58+
Xcode might be able to do this for you. These are manual instructions.
59+
60+
Use `Certificate Assistant`:
61+
1. Open `Keychain Access`
62+
2. `Keychain Access` menu -> `Certificate Assistent` -> `Request a Certificate from a CA`
63+
3. Use your apple id email address (might not matter)
64+
4. Maybe sure it's saved to disk
65+
5. Save the CSR somewhere
66+
67+
Login to https://developer.apple.com/
68+
69+
You should have access to the osquery account, `3522FA9PXF`. If you
70+
have multiple accounts, it will be in the top right pulldown.
71+
72+
Click `Certificates, Identifiers & Profiles` and create a certificate.
73+
74+
You'll want either an `Apple Development` or a `Mac Development`
75+
certificate.
76+
77+
Upload the CSR generated earlier.
78+
79+
You should now be able to download the certificate.
80+
81+
### Back to the Admin
82+
83+
Now the admin will have to add the developer and the device to the
84+
profile. Or create one specific to this developer. Probably doesn't
85+
matter much.
86+
87+
### Back to the developer
88+
89+
Finally, you can download a profile. This needs to be installed on the
90+
machines to allow the machine to trust the code signing.
91+
92+
## How to Use Endpoint Security
93+
94+
_*NOTE*: you need to be building on catalina or later_
95+
96+
Build something. This is using some demo esf code:
97+
98+
Cannot run without any signatures:
99+
100+
``` shell
101+
$ ./endpointsecurity
102+
client lacks entitlement
103+
```
104+
105+
106+
Code sign without entitlements
107+
108+
``` shell
109+
$ codesign --force -s "${CODESIGN_IDENTITY}" -v --options runtime,library --timestamp ./endpointsecurity
110+
111+
$ ./endpointsecurity
112+
client lacks entitlement
113+
```
114+
115+
Finally, with entitlements.
116+
117+
``` shell
118+
$ codesign --force -s "${CODESIGN_IDENTITY}" -v --options runtime,library --timestamp --entitlements endpointsecurity.entitlements ./endpointsecurity
119+
120+
$ ./endpointsecurity.entitled
121+
Killed: 9
122+
```
123+
124+
125+
Oh no! We still need to install the profile authorizing this host.
126+
127+
Still `killed: 9`

0 commit comments

Comments
 (0)