You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
This page contains detailed instructions on how to configure `cosign` to work with KMS providers.
8
-
Right now `cosign` supports Hashicorp Vault, AWS KMS, and GCP KMS, and we are hoping to support more in the future!
8
+
Right now `cosign` supports [AWS KMS](https://aws.amazon.com/kms/), [GCP KMS](https://cloud.google.com/security-key-management), [Azure Key Vault](https://azure.microsoft.com/en-gb/products/key-vault), [Hashicorp Vault](https://www.vaultproject.io/)and [Kubernetes Secrets](https://kubernetes.io/docs/concepts/configuration/secret/) with the hope to support more in the future!
9
9
10
+
## Basic Usage
11
+
12
+
When referring to a key managed by a KMS provider, `cosign` takes a [go-cloud](https://gocloud.dev) style URI to refer to the specific provider.
13
+
14
+
For example: `awskms://`, `gcpkms://`, `azurekms://`, `hashivault://` and `k8s://`. The URI path syntax is provider specific and explained in the section for each provider.
15
+
16
+
### Key Generation and Management
17
+
18
+
To generate keys using a KMS provider, you can use the `cosign generate-key-pair` command with the `--kms` flag.
This section contains the provider-specific documentation.
14
71
15
-
16
72
### AWS
17
73
18
74
AWS KMS keys can be used in `cosign` for signing and verification.
19
-
The URI format for AWS KMS is:
20
-
21
-
`awskms://$ENDPOINT/$KEYID`
22
-
23
-
where ENDPOINT and KEYID are replaced with the correct values.
75
+
The URI format for AWS KMS is `awskms://$ENDPOINT/$KEYID` where `$ENDPOINT` and `$KEYID` are replaced with the correct values.
24
76
25
-
The ENDPOINT value is left blank in most scenarios, but can be set for testing with KMS-compatible servers such as [localstack](https://localstack.cloud/).
77
+
The `$ENDPOINT` value is left blank in most scenarios, but can be set for testing with KMS-compatible servers such as [localstack](https://localstack.cloud/).
26
78
If omitting a custom endpoint, it is mandatory to prefix the URI with `awskms:///` (with three slashes).
27
79
28
-
If a custom endpoint is used, you may disable TLS verification by setting an environment variable:`AWS_TLS_INSECURE_SKIP_VERIFY=1`.
80
+
If a custom endpoint is used, you may disable TLS verification by setting an environment variable `AWS_TLS_INSECURE_SKIP_VERIFY=1`.
29
81
30
82
AWS credentials are provided using standard configuration as [described in AWS docs](https://docs.aws.amazon.com/sdk-for-go/v1/developer-guide/configuring-sdk.html#specifying-credentials).
31
83
32
-
The KEYID value must conform to any [AWS KMS key identifier](https://docs.aws.amazon.com/kms/latest/developerguide/concepts.html#key-id)
33
-
format as described in the linked document (Key ARN, Key ID, Alias ARN, or Alias ID).
84
+
The `$KEYID` value must conform to any [AWS KMS key identifier](https://docs.aws.amazon.com/kms/latest/developerguide/concepts.html#key-id) format as described in the linked document (Key ARN, Key ID, Alias ARN, or Alias ID).
34
85
35
-
Note that key creation is not supported by cosign if using the Key ARN or Key ID formats, so it is recommended to use [Key Aliases](https://docs.aws.amazon.com/kms/latest/developerguide/kms-alias.html)
36
-
for most situations.
86
+
Note that key creation is not supported by cosign if using the Key ARN or Key ID formats, so it is recommended to use [Key Aliases](https://docs.aws.amazon.com/kms/latest/developerguide/kms-alias.html) for most situations.
37
87
38
88
The following URIs are valid:
39
89
@@ -46,50 +96,93 @@ The following URIs are valid:
46
96
- Alias ARN: `awskms:///arn:aws:kms:us-east-2:111122223333:alias/ExampleAlias`
47
97
- Alias ARN with endpoint: `awskms://localhost:4566/arn:aws:kms:us-east-2:111122223333:alias/ExampleAlias`
where PROJECT, LOCATION, KEYRING, KEY and KEY_VERSION are replaced with the correct values.
123
+
Where `$PROJECT`, `$LOCATION`, `$KEYRING`, `$KEY` and `$KEY_VERSION` are replaced with the correct values.
57
124
58
-
Cosign automatically uses GCP Application Default Credentials for authentication.
59
-
See the GCP [API documentation](https://cloud.google.com/docs/authentication/production) for information on how to authenticate in different environments.
125
+
Cosign automatically uses GCP Application Default Credentials for authentication. See the GCP [API documentation](https://cloud.google.com/docs/authentication/production) for information on how to authenticate in different environments.
Azure Key Vault keys can be used in `cosign` for signing and verification.
132
+
### Azure Key Vault
68
133
69
-
The URI format for Azure Key Vault is:
70
-
`azurekms://[VAULT_NAME][VAULT_URI]/[KEY]`
134
+
Azure Key Vault keys can be used in `cosign` for signing and verification. The URI format for Azure Key Vault is:
135
+
`azurekms://[VAULT_NAME][VAULT_URI]/[KEY]` where `$VAULT_NAME`, `$VAULT_URI`, and `$KEY` are replaced with the correct values.
71
136
72
-
where VAULT_NAME, VAULT_URI, and KEY are replaced with the correct values.
137
+
The following environment variables must be set to let cosign authenticate to Azure Key Vault. (see this [reference](https://devblogs.microsoft.com/azure-sdk/authentication-and-the-azure-sdk/#environment-variables) for more details about Azure SDK Authentication):
73
138
74
-
The following environment variables must be set to let cosign authenticate to Azure Key Vault. (see this [reference](https://devblogs.microsoft.com/azure-sdk/authentication-and-the-azure-sdk/#environment-variables) for more details about Azure SDK Authentication)
75
-
- AZURE_TENANT_ID
76
-
- AZURE_CLIENT_ID
77
-
- AZURE_CLIENT_SECRET
139
+
-`AZURE_TENANT_ID`
140
+
-`AZURE_CLIENT_ID`
141
+
-`AZURE_CLIENT_SECRET`
78
142
79
143
To create a key using `cosign generate-key-pair --kms azurekms://[VAULT_NAME][VAULT_URI]/[KEY]` you will need a user which has permissions to create keys in Key Vault. For example `Key Vault Crypto Officer` role.
80
144
81
-
To sign images using `cosign sign --key azurekms://[VAULT_NAME][VAULT_URI]/[KEY] [IMAGE]` you will need a user which has permissions to the sign action such as the `Key Vault Crypto User` role.
145
+
To sign images using `cosign sign --key azurekms://[VAULT_NAME][VAULT_URI]/[KEY] [IMAGE_DIGEST]` you will need a user which has permissions to the sign action such as the `Key Vault Crypto User` role.
82
146
83
147
### Hashicorp Vault
84
148
85
149
Hashicorp Vault keys can be used in `cosign` for signing and verification.
86
-
The URI format for Hashicorp Vault KMS is:
150
+
The URI format for Hashicorp Vault KMS is:`hashivault://$keyname`
87
151
88
-
`hashivault://$keyname`
89
-
90
-
This provider requires that the standard Vault environment variables (VAULT_ADDR, VAULT_TOKEN) are set correctly.
152
+
This provider requires that the standard Vault environment variables (`$VAULT_ADDR`, `$VAULT_TOKEN`) are set correctly.
91
153
This provider also requires that the `transit` secret engine is enabled.
92
154
155
+
### Kubernetes Secret
156
+
157
+
Cosign can use keys stored in Kubernetes Secrets to so sign and verify signatures. In order to generate a secret you have to pass `cosign generate-key-pair` a `k8s://[NAMESPACE]/[NAME]` URI specifying the namespace and secret name:
Successfully created secret testsecret in namespace default
164
+
Public key written to cosign.pub
165
+
```
166
+
167
+
After generating the key pair, cosign will store it in a Kubernetes secret using your current context. The secret will contain the private and public keys, as well as the password to decrypt the private key.
When verifying an image signature using `cosign verify`, the key will be automatically decrypted using the password stored in the kubernetes secret under the `cosign.password` field.
185
+
93
186
#### Local Setup
94
187
95
188
For a local setup, you can run Vault yourself or use the `docker-compose` file from [sigstore/sigstore](https://github.com/sigstore/sigstore/blob/main/test/e2e/docker-compose.yml) as an example.
0 commit comments