1
- # Create private key and Certificate Signing Request (CSR)
1
+ ## Dependencies
2
2
3
- ## Create new private key and CSR
3
+ One needs Go v1.19 and the latest stable rust to build the app.
4
+ Go can be installed via
5
+ ``` bash
6
+ brew install go@1.19
7
+ ```
8
+
9
+ Rust should be installed via [ rustup] ( https://rustup.rs ) . Once rust is
10
+ installed, do not forget to install the iOS targets:
11
+
12
+ ``` bash
13
+ rustup target install aarch64-apple-ios aarch64-apple-ios-sim x86_64-apple-ios
14
+ ```
15
+ Pick between the ARM or x86 simulator targets, selecting the one that matches
16
+ the host system.
17
+
18
+ Once both rust and go are installed, ensure they are available in your path.
19
+
20
+ ## Configure Xcode project
21
+
22
+ Copy template files of Xcode build configuration:
23
+
24
+ ```
25
+ for file in ./ios/Configurations/*.template ; do cp $file ${file//.template/} ; done
26
+ ```
27
+
28
+ Template files provide our team ID and correct provisioning profiles and generally do not require
29
+ any changes when configuring our build server or developer machines for members of Mullvad
30
+ development team. In all other cases perform the following steps to configure the project:
31
+
32
+ 1 . Edit ` Base.xcconfig ` and fill in your Apple development team ID, which can be found on Apple
33
+ developer portal in the top right corner next to your organization name (uppercase letters and
34
+ digits).
35
+ 1 . Edit ` App.xcconfig ` and ` PacketTunnel.xcconfig ` and supply the names of your provisioning profiles
36
+ for development (Debug) and distribution (Release).
37
+ 1 . Edit ` Screenshots.xcconfig ` and supply the name of your provisioning profile. We only specify
38
+ development profile here as we never build UI testing targets for distribution. Skip this step if
39
+ you do not intend to generate screenshots for the app.
40
+
41
+ Ensure you have a valid build profile for a development build for both
42
+ MullvadVPN and PacketTunnel, both need the
43
+ ` packet-tunnel-provider-systemextension ` NetworkExtension entitlement.
4
44
5
- OpenSSL will ask you the password for the private key, make sure to memorize it, you'll need it
45
+ # The following instructions are only relevant for release builds.
46
+
47
+ ## Create private key and Certificate Signing Request (CSR)
48
+ ### Create new private key and CSR
49
+
50
+ OpenSSL will ask you the password for the private key, make sure to memorize it, you'll need it
6
51
later.
7
52
8
53
```
@@ -13,7 +58,7 @@ openssl req -new -newkey rsa:2048 \
13
58
-subj "/C=SE/O=<ORGANIZATION_NAME>/emailAddress=<YOUR_EMAIL>"
14
59
```
15
60
16
- ## [ Alternative] Create CSR using an existing private key
61
+ ### [ Alternative] Create CSR using an existing private key
17
62
18
63
```
19
64
openssl req -new \
@@ -23,15 +68,15 @@ openssl req -new \
23
68
-subj "/C=SE/O=<ORGANIZATION_NAME>/emailAddress=<YOUR_EMAIL>"
24
69
```
25
70
26
- # Upload Certificate Signing Request (CSR) to Apple
71
+ ## Upload Certificate Signing Request (CSR) to Apple
27
72
28
73
1 . Go to https://developer.apple.com/account/resources/certificates/list
29
74
1 . Click the plus button (+) in the heading to create a new certificate
30
75
1 . Select "Apple Distribution" option from the given list, press "Continue"
31
76
1 . Select the previously created ` cert_signing_request ` file for upload
32
77
1 . Download the provided ` distribution.cer ` on disk
33
78
34
- # Download Apple WWDR certificate
79
+ ## Download Apple WWDR certificate
35
80
36
81
WWDR certificate is used to verify the development and distribution certificates issued by Apple.
37
82
@@ -51,7 +96,7 @@ openssl x509 -inform der -outform pem \
51
96
-out AppleWWDRCAG3.pem
52
97
```
53
98
54
- # Export private key and certificates
99
+ ## Export private key and certificates
55
100
56
101
Produce a PKCS12 container with the private key and all certificates. You will be asked to enter two
57
102
passphrases:
@@ -60,7 +105,7 @@ passphrases:
60
105
1 . Export passphrase for PKCS12 file
61
106
62
107
You can store the produced ` apple_code_signing.p12 ` file as a backup to be able to restore the keys
63
- in the event of hardware failure. However you should always be able to re-create everything from
108
+ in the event of hardware failure. However you should always be able to re-create everything from
64
109
scratch.
65
110
66
111
```
@@ -72,11 +117,11 @@ openssl pkcs12 -export \
72
117
-name "<FRIENDLY_KEYCHAIN_NAME>"
73
118
```
74
119
75
- # Remove old private key and certificates from Keychain
120
+ ## Remove old private key and certificates from Keychain
76
121
77
122
__ Skip this section if you create the private key for the very first time.__
78
123
79
- If you happen to re-create the keys, you will have to remove the old keys and certificates from
124
+ If you happen to re-create the keys, you will have to remove the old keys and certificates from
80
125
Keychain.
81
126
82
127
You can list all certificates with corresponding keys by using the following command:
@@ -93,33 +138,33 @@ Valid identities only
93
138
2) <HASH_ID> "Apple Development: <COMPANY NAME> (<TEAM ID>)"
94
139
```
95
140
96
- Pick the one that you don't want anymore and copy the ` <HASH_ID> ` from the output, then paste into
141
+ Pick the one that you don't want anymore and copy the ` <HASH_ID> ` from the output, then paste into
97
142
the command below:
98
143
99
144
```
100
145
security delete-identity -Z <HASH_ID>
101
146
```
102
147
103
- This should take care of removing both private keys and certificates. Repeat as many times as needed
148
+ This should take care of removing both private keys and certificates. Repeat as many times as needed
104
149
if you wish to remove multiple identities.
105
150
106
- # Import private key and certificates into Keychain
151
+ ## Import private key and certificates into Keychain
107
152
108
153
```
109
154
security import apple_code_signing.p12 -f pkcs12 \
110
155
-T /usr/bin/codesign \
111
156
-P <EXPORT_PASSPHRASE>
112
157
```
113
158
114
- Note: ` -T /usr/bin/codesign ` instructs Keychain to suppress password prompt during code signing,
115
- although you still have to unlock Keychain for that to have any effect. This instruction is
116
- equivalent to choosing "Always allow" in the password prompt GUI on the first run of ` codesign `
159
+ Note: ` -T /usr/bin/codesign ` instructs Keychain to suppress password prompt during code signing,
160
+ although you still have to unlock Keychain for that to have any effect. This instruction is
161
+ equivalent to choosing "Always allow" in the password prompt GUI on the first run of ` codesign `
117
162
tool.
118
163
119
- Note: providing the export passphrase using the ` -P ` flag is considered unsafe.
164
+ Note: providing the export passphrase using the ` -P ` flag is considered unsafe.
120
165
Leave the ` -P <EXPORT_PASSPHRASE> ` out to enter the passphrase via GUI.
121
166
122
- Technically after that you can clean up all created keys and certificates since all of them are
167
+ Technically after that you can clean up all created keys and certificates since all of them are
123
168
securely stored in Keychain now.
124
169
125
170
```
@@ -130,7 +175,7 @@ rm distribution.{pem,cer} \
130
175
private_key.pem
131
176
```
132
177
133
- # Create iOS provisioning profiles
178
+ ## Create iOS provisioning profiles
134
179
135
180
We will now create the provisioning profiles listed below using the Apple developer console.
136
181
@@ -145,14 +190,14 @@ Follow these steps to add each of provisioning profiles:
145
190
1 . Click the plus button (+) in the heading to create a new provisioning profile
146
191
1 . Choose "App Store" under "Distribution", then hit "Continue"
147
192
1 . Choose the App ID (see the table above) and hit "Continue"
148
- 1 . Choose the distribution certificate that you had created after uploading the CSR
193
+ 1 . Choose the distribution certificate that you had created after uploading the CSR
149
194
(i.e ` <ORGANIZATION_NAME> (Distribution) ` )
150
195
1 . Type in the profile name (see the table above) and hit "Generate"
151
- 1 . Download the certificate in ` ios/iOS Provisioning Profiles ` directory. Create the directory if it
152
- does not exist.
153
-
196
+ 1 . Download the certificate in ` ios/iOS Provisioning Profiles ` directory. Create the directory if it
197
+ does not exist.
198
+
154
199
Note: you can use a different directory for storing provisioning profiles, however in that case,
155
- make sure to provide the path to the custom location via ` IOS_PROVISIONING_PROFILES_DIR `
200
+ make sure to provide the path to the custom location via ` IOS_PROVISIONING_PROFILES_DIR `
156
201
environment variable when running ` build.sh ` (more on that later).
157
202
158
203
# Setup AppStore credentials
@@ -166,8 +211,8 @@ environment variables:
166
211
167
212
` IOS_APPLE_ID_PASSWORD ` accepts a keychain reference in form of ` @keychain:<KEYCHAIN_ITEM_NAME> ` .
168
213
169
- Use the app specific password instead of the actual account password and save it to Keychain.
170
- The app specific password can be created via [ Apple ID website] and added to Keychain using the
214
+ Use the app specific password instead of the actual account password and save it to Keychain.
215
+ The app specific password can be created via [ Apple ID website] and added to Keychain using the
171
216
following command (note that ` altool ` will be authorized to access the saved password):
172
217
173
218
```
@@ -178,38 +223,7 @@ xcrun altool --store-password-in-keychain-item <KEYCHAIN_ITEM_NAME> \
178
223
179
224
[ Apple ID website ] : https://appleid.apple.com/account/manage
180
225
181
- # Configure Xcode project
182
-
183
- Copy template files of Xcode build configuration:
184
-
185
- ```
186
- for file in ./ios/Configurations/*.template ; do cp $file ${file//.template/} ; done
187
- ```
188
-
189
- Template files provide our team ID and correct provisioning profiles and generally do not require
190
- any changes when configuring our build server or developer machines for members of Mullvad
191
- development team. In all other cases perform the following steps to configure the project:
192
-
193
- 1 . Edit ` Base.xcconfig ` and fill in your Apple development team ID, which can be found on Apple
194
- developer portal in the top right corner next to your organization name (uppercase letters and
195
- digits).
196
- 1 . Edit ` App.xcconfig ` and ` PacketTunnel.xcconfig ` and supply the names of your provisioning profiles
197
- for development (Debug) and distribution (Release).
198
- 1 . Edit ` Api.xcconfig ` to supply the endpoint that will be used to reach the Mullvad API.
199
- 1 . Edit ` Screenshots.xcconfig ` and supply the name of your provisioning profile. We only specify
200
- development profile here as we never build UI testing targets for distribution. Skip this step if
201
- you do not intend to generate screenshots for the app.
202
-
203
- # Automated build and deployment
204
-
205
- Build script does not bump the build number, so make sure to edit ` Configurations/Version.xcconfig `
206
- and commit it back to repo.
207
-
208
- 1 . Run ` ./ios/build.sh ` to build and export the app for upload to AppStore.
209
- 1 . Run ` ./ios/build.sh --deploy ` - same as above but also uploads the app to AppStore and
210
- makes it available over TestFlight.
211
-
212
- # Keychain quirks
226
+ ## Keychain quirks
213
227
214
228
It's possible that ` codesign ` will keep throwing the password prompts for Keychain, in that case try
215
229
running the following commands __ after__ importing the credentials into Keychain:
@@ -219,7 +233,7 @@ security unlock-keychain <KEYCHAIN>
219
233
security set-key-partition-list -S apple-tool:,apple: -s <KEYCHAIN>
220
234
```
221
235
222
- where ` <KEYCHAIN> ` is the name of the target Keychain where the signing credentials are stored.
236
+ where ` <KEYCHAIN> ` is the name of the target Keychain where the signing credentials are stored.
223
237
This guide does not use a separate Keychain store, so use ` login.keychain-db ` then.
224
238
225
239
Reference: https://docs.travis-ci.com/user/common-build-problems/#mac-macos-sierra-1012-code-signing-errors
0 commit comments