Skip to content

Commit a81a03b

Browse files
added signing
1 parent 2774742 commit a81a03b

15 files changed

+49
-39
lines changed
255 KB
Loading
292 KB
Loading
266 KB
Loading
275 KB
Loading

assets/images/spm_ca_create_1.jpg

234 KB
Loading

assets/images/spm_ca_create_2.jpg

244 KB
Loading

assets/images/spm_cert_create_1.jpg

-232 KB
Binary file not shown.

assets/images/spm_cert_create_2.jpg

-222 KB
Binary file not shown.

assets/images/spm_cert_create_3.jpg

-237 KB
Binary file not shown.

assets/images/spm_cert_create_4.jpg

-254 KB
Binary file not shown.

assets/images/spm_cert_create_5.jpg

-236 KB
Binary file not shown.

assets/images/spm_cert_export.jpg

216 KB
Loading

docs/openspmregistry/packagesigning.md

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -45,3 +45,26 @@ save this file as `package-metadata.json`
4545
- [Create via Keychain](packagesigningkeychain.md)
4646
- [Create manually via commandline](packagesigningmanual.md)
4747

48+
### 3. Trusted store configuration
49+
Add the following to [(Security Configuration)](https://github.com/swiftlang/swift-package-manager/blob/main/Documentation/PackageRegistry/PackageRegistryUsage.md#security-configuration){:target="_blank"}
50+
in ```~/.swiftpm/configuration/registries.json```
51+
```json
52+
{
53+
"security": {
54+
"default": {
55+
"signing": {
56+
"onUnsigned": "error",
57+
"onUntrustedCertificate": "error",
58+
"trustedRootCertificatesPath": "/Users/[user]/.swiftpm/security/trusted-root-certs/",
59+
"includeDefaultTrustedRootCertificates": true,
60+
"validationChecks": {
61+
"certificateExpiration": "disabled",
62+
"certificateRevocation": "disabled"
63+
}
64+
}
65+
}
66+
},
67+
...
68+
}
69+
```
70+
This will ensure the signing is checked and the certificate is trusted by the client (xcode and/or swift-package).

docs/openspmregistry/packagesigningkeychain.md

Lines changed: 19 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -7,21 +7,28 @@ nav_order: 1
77
# Sign & create via Keychain_
88
_Create a self-signed certificate via Keychain_
99

10-
## Create a Certificate
10+
### Create a Certificate
1111
1. Open keychain
12-
2. Create new certificate
12+
2. Go to Certificate Assistant > Create a Certificate Authority
13+
![Create CA 1](../../assets/images/spm_ca_create_1.jpg)
14+
![Create CA 2](../../assets/images/spm_ca_create_2.jpg)
15+
3. Go to Certificate Assistant > Create a Certificate
16+
3.a. Overwrite the default settings (leaf, code signing)
17+
![Create Cert 1](../../assets/images/spm_ca_cert_create_1.jpg)
18+
3.b. Choose previously created CA
19+
![Create Cert 2](../../assets/images/spm_ca_cert_create_2.jpg)
20+
3.c. Change Key Pair Information to ECC and 256 bits
21+
![Create Cert 3](../../assets/images/spm_ca_cert_create_3.jpg)
22+
3.d. Ensure Code Signing is enabled
23+
![Create Cert 4](../../assets/images/spm_ca_cert_create_4.jpg)
24+
4. Save it to keychain
1325

14-
![Create Cert 1](../../assets/images/spm_cert_create_1.jpg)
15-
2a. Overright the default settings
16-
![Create Cert 2](../../assets/images/spm_cert_create_2.jpg)
17-
2b. Change Key Pair Information to ECC and 256 bits
18-
![Create Cert 3](../../assets/images/spm_cert_create_3.jpg)
19-
![Create Cert 4](../../assets/images/spm_cert_create_4.jpg)
20-
2c. Ensure Code Signing is enabled
21-
![Create Cert 5](../../assets/images/spm_cert_create_5.jpg)
22-
3. Save it to keychain
26+
### Add CA to trusted root
27+
1. Export the CA
28+
![Export CA](../../assets/images/spm_cert_export.jpg)
29+
2. Save in as CER in the trusted root dir: `~/.swiftpm/security/trusted-root-certs/`
2330

24-
## Sign a Package & Publish
31+
### Sign a Package & Publish
2532
```shell
2633
swift package-registry publish [scope].[Package] [version] \
2734
--metadata-path package-metadata.json \

docs/openspmregistry/packagesigningmanual.md

Lines changed: 7 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -5,14 +5,16 @@ nav_order: 2
55
---
66

77
# Sign & create cert manually
8-
Manually create a self-signed certificate via commandline
8+
Manually create a self-signed certificate via commandline.
9+
{: .warning }
10+
Might be outdated or not working on your system. Recommend to use [Keychain](packagesigningkeychain.md) instead.
911

10-
#### Create a CA
12+
### Create a CA
1113
```shell
1214
openssl genpkey -algorithm RSA -outform der -out ca.key -pkeyopt rsa_keygen_bits:2048
1315
openssl req -x509 -new -nodes -key ca.key -sha256 -days 365 -outform der -out ca.crt -subj "/C=US/ST=State/L=City/O=Organization/OU=OrgUnit/CN=RootCA"
1416
```
15-
#### Create a certificate
17+
### Create a certificate
1618
```shell
1719
openssl ecparam -genkey -name prime256v1 -outform der -out ecdsa.key
1820
openssl pkcs8 -topk8 -inform DER -outform PEM -in ecdsa.key -out ecdsa_temp.pem -nocrypt
@@ -33,33 +35,11 @@ extendedKeyUsage = codeSigning" > code_signing_ext.cnf
3335

3436
openssl x509 -req -in ecdsa.csr -CA ca.crt -CAkey ca.key -CAcreateserial -outform der -out ecdsa.crt -days 365 -sha256 -extfile code_signing_ext.cnf -extensions v3_code_sign
3537
```
36-
#### Add CA to trusted root
38+
### Add CA to trusted root
3739
```
3840
cp ca.crt ~/.swiftpm/security/trusted-root-certs/ca.cer
3941
```
40-
##### Trusted store configuration
41-
Add the following to [(Security Configuration)](https://github.com/swiftlang/swift-package-manager/blob/main/Documentation/PackageRegistry/PackageRegistryUsage.md#security-configuration){:target="_blank"}
42-
in ```~/.swiftpm/configuration/registries.json```
43-
```json
44-
{
45-
"security": {
46-
"default": {
47-
"signing": {
48-
"onUnsigned": "error",
49-
"onUntrustedCertificate": "error",
50-
"trustedRootCertificatesPath": "/Users/[user]/.swiftpm/security/trusted-root-certs/",
51-
"includeDefaultTrustedRootCertificates": true,
52-
"validationChecks": {
53-
"certificateExpiration": "disabled",
54-
"certificateRevocation": "disabled"
55-
}
56-
}
57-
}
58-
},
59-
...
60-
}
61-
```
62-
#### publish with signing
42+
### publish with signing
6343
```shell
6444
swift package-registry publish [scope].[Package] [version] \
6545
--metadata-path package-metadata.json \

0 commit comments

Comments
 (0)