github.com/argoproj/argo-cd/v3@v3.2.1/docs/user-guide/gpg-verification.md (about) 1 # GnuPG signature verification 2 3 ## Overview 4 5 As of v1.7 it is possible to configure ArgoCD to only sync against commits 6 that are signed in Git using GnuPG. Signature verification is configured on 7 project level. 8 9 If a project is configured to enforce signature verification, all applications 10 associated with this project must have the commits in the source repositories 11 signed with a GnuPG public key known to ArgoCD. ArgoCD will refuse to sync to 12 any revision that does not have a valid signature made by one of the configured 13 keys. The controller will emit a `ResourceComparison` error if it tries to sync 14 to a revision that is either not signed, or is signed by an unknown or not 15 allowed public key. 16 17 By default, signature verification is enabled but not enforced. If you wish to 18 completely disable the GnuPG functionality in ArgoCD, you have to set the 19 environment variable `ARGOCD_GPG_ENABLED` to `"false"` in the pod templates of 20 the `argocd-server`, `argocd-repo-server`, `argocd-application-controller` and 21 `argocd-applicationset-controller` deployment manifests. 22 23 Verification of GnuPG signatures is only supported with Git repositories. It is 24 not possible using Helm repositories. 25 26 !!!note "A few words about trust" 27 ArgoCD uses a very simple trust model for the keys you import: Once the key 28 is imported, ArgoCD will trust it. ArgoCD does not support more complex 29 trust models, and it is not necessary (nor possible) to sign the public keys 30 you are going to import into ArgoCD. 31 32 33 !!!note Limitations 34 Signature verification is not supported for the templated `project` field when 35 using the Git generator. 36 37 ## Signature verification targets 38 39 If signature verification is enforced, ArgoCD will verify the signature using 40 following strategy: 41 42 * If `target revision` is a pointer to a commit object (i.e. a branch name, the 43 name of a reference such as `HEAD` or a commit SHA), ArgoCD will perform the 44 signature verification on the commit object the name points to, i.e. a commit. 45 46 * If `target revision` resolves to a tag and the tag is a lightweight tag, the 47 behaviour is same as if `target revision` would be a pointer to a commit 48 object. However, if the tag is annotated, the target revision will point to 49 a *tag* object and thus, the signature verification is performed on the tag 50 object, i.e. the tag itself must be signed (using `git tag -s`). 51 52 ## Enforcing signature verification 53 54 To configure enforcing of signature verification, the following steps must be 55 performed: 56 57 * Import the GnuPG public key(s) used for signing commits in ArgoCD 58 * Configure a project to enforce signature verification for given keys 59 60 Once you have configured one or more keys to be required for verification for 61 a given project, enforcement is active for all applications associated with 62 this project. 63 64 !!!warning 65 If signature verification is enforced, you will not be able to sync from 66 local sources (i.e. `argocd app sync --local`) anymore. 67 68 ## RBAC rules for managing GnuPG keys 69 70 The appropriate resource notation for Argo CD's RBAC implementation to allow 71 the managing of GnuPG keys is `gpgkeys`. 72 73 To allow listing of keys for a role named `role:myrole`, use: 74 75 ``` 76 p, role:myrole, gpgkeys, get, *, allow 77 ``` 78 79 To allow adding keys for a role named `role:myrole`, use: 80 81 ``` 82 p, role:myrole, gpgkeys, create, *, allow 83 ``` 84 85 And finally, to allow deletion of keys for a role named `role:myrole`, use: 86 87 ``` 88 p, role:myrole, gpgkeys, delete, *, allow 89 ``` 90 91 ## Importing GnuPG public keys 92 93 You can configure the GnuPG public keys that ArgoCD will use for verification 94 of commit signatures using either the CLI, the web UI or configuring it using 95 declarative setup. 96 97 !!!note 98 After you have imported a GnuPG key, it may take a while until the key is 99 propagated within the cluster, even if listed as configured. If you still 100 cannot sync to commits signed by the already imported key, please see the 101 troubleshooting section below. 102 103 Users wanting to manage the GnuPG public key configuration require the RBAC 104 permissions for `gpgkeys` resources. 105 106 ### Manage public keys using the CLI 107 108 To configure GnuPG public keys using the CLI, use the `argocd gpg` command. 109 110 #### Listing all configured keys 111 112 To list all configured keys known to ArgoCD, use the `argocd gpg list` 113 sub-command: 114 115 ```bash 116 argocd gpg list 117 ``` 118 119 #### Show information about a certain key 120 121 To get information about a specific key, use the `argocd gpg get` sub-command: 122 123 ```bash 124 argocd gpg get <key-id> 125 ``` 126 127 #### Importing a key 128 129 To import a new key to ArgoCD, use the `argocd gpg add` sub-command: 130 131 ```bash 132 argocd gpg add --from <path-to-key> 133 ``` 134 135 The key to be imported can be either in binary or ASCII-armored format. 136 137 #### Removing a key from configuration 138 139 To remove a previously configured key from the configuration, use the 140 `argocd gpg rm` sub-command: 141 142 ```bash 143 argocd gpg rm <key-id> 144 ``` 145 146 ### Manage public keys using the Web UI 147 148 Basic key management functionality for listing, importing and removing GnuPG 149 public keys is implemented in the Web UI. You can find the configuration 150 module from the **Settings** page in the **GnuPG keys** module. 151 152 Please note that when you configure keys using the Web UI, the key must be 153 imported in ASCII armored format for now. 154 155 ### Manage public keys in declarative setup 156 157 ArgoCD stores public keys internally in the `argocd-gpg-keys-cm` ConfigMap 158 resource, with the public GnuPG key's ID as its name and the ASCII armored 159 key data as string value, i.e. the entry for the GitHub's web-flow signing 160 key would look like follows: 161 162 ```yaml 163 4AEE18F83AFDEB23: | 164 -----BEGIN PGP PUBLIC KEY BLOCK----- 165 166 mQENBFmUaEEBCACzXTDt6ZnyaVtueZASBzgnAmK13q9Urgch+sKYeIhdymjuMQta 167 x15OklctmrZtqre5kwPUosG3/B2/ikuPYElcHgGPL4uL5Em6S5C/oozfkYzhwRrT 168 SQzvYjsE4I34To4UdE9KA97wrQjGoz2Bx72WDLyWwctD3DKQtYeHXswXXtXwKfjQ 169 7Fy4+Bf5IPh76dA8NJ6UtjjLIDlKqdxLW4atHe6xWFaJ+XdLUtsAroZcXBeWDCPa 170 buXCDscJcLJRKZVc62gOZXXtPfoHqvUPp3nuLA4YjH9bphbrMWMf810Wxz9JTd3v 171 yWgGqNY0zbBqeZoGv+TuExlRHT8ASGFS9SVDABEBAAG0NUdpdEh1YiAod2ViLWZs 172 b3cgY29tbWl0IHNpZ25pbmcpIDxub3JlcGx5QGdpdGh1Yi5jb20+iQEiBBMBCAAW 173 BQJZlGhBCRBK7hj4Ov3rIwIbAwIZAQAAmQEH/iATWFmi2oxlBh3wAsySNCNV4IPf 174 DDMeh6j80WT7cgoX7V7xqJOxrfrqPEthQ3hgHIm7b5MPQlUr2q+UPL22t/I+ESF6 175 9b0QWLFSMJbMSk+BXkvSjH9q8jAO0986/pShPV5DU2sMxnx4LfLfHNhTzjXKokws 176 +8ptJ8uhMNIDXfXuzkZHIxoXk3rNcjDN5c5X+sK8UBRH092BIJWCOfaQt7v7wig5 177 4Ra28pM9GbHKXVNxmdLpCFyzvyMuCmINYYADsC848QQFFwnd4EQnupo6QvhEVx1O 178 j7wDwvuH5dCrLuLwtwXaQh0onG4583p0LGms2Mf5F+Ick6o/4peOlBoZz48= 179 =Bvzs 180 -----END PGP PUBLIC KEY BLOCK----- 181 ``` 182 183 ## Configuring a project to enforce signature verification 184 185 Once you have imported the GnuPG keys to ArgoCD, you must now configure the 186 project to enforce the verification of commit signatures with the imported 187 keys. 188 189 ### Configuring using the CLI 190 191 #### Adding a key ID to list of allowed keys 192 193 To add a key ID to the list of allowed GnuPG keys for a project, you can use 194 the `argocd proj add-signature-key` command, i.e. the following command would 195 add the key ID `4AEE18F83AFDEB23` to the project named `myproj`: 196 197 ```bash 198 argocd proj add-signature-key myproj 4AEE18F83AFDEB23 199 ``` 200 201 #### Removing a key ID from the list of allowed keys 202 203 Similarly, you can remove a key ID from the list of allowed GnuPG keys for a 204 project using the `argocd proj remove-signature-key` command, i.e. to remove 205 the key added above from project `myproj`, use the command: 206 207 ```bash 208 argocd proj remove-signature-key myproj 4AEE18F83AFDEB23 209 ``` 210 211 #### Showing allowed key IDs for a project 212 213 To see which key IDs are allowed for a given project, you can inspect the 214 output of the `argocd proj get` command, i.e. for a project named `gpg`: 215 216 ```bash 217 $ argocd proj get gpg 218 Name: gpg 219 Description: GnuPG verification 220 Destinations: *,* 221 Repositories: * 222 Allowed Cluster Resources: */* 223 Denied Namespaced Resources: <none> 224 Signature keys: 4AEE18F83AFDEB23, 07E34825A909B250 225 Orphaned Resources: disabled 226 ``` 227 228 #### Override list of key IDs 229 230 You can also explicitly set the currently allowed keys with one or more new keys 231 using the `argocd proj set` command in combination with the `--signature-keys` 232 flag, which you can use to specify a comma separated list of allowed key IDs: 233 234 ```bash 235 argocd proj set myproj --signature-keys 4AEE18F83AFDEB23,07E34825A909B250 236 ``` 237 238 The `--signature-keys` flag can also be used on project creation, i.e. the 239 `argocd proj create` command. 240 241 ### Configure using the Web UI 242 243 You can configure the GnuPG key IDs required for signature verification using 244 the web UI, in the Project configuration. Navigate to the **Settings** page 245 and select the **Projects** module, then click on the project you want to 246 configure. 247 248 From the project's details page, click **Edit** and find the 249 **Required signature keys** section, where you can add or remove the key IDs 250 for signature verification. After you have modified your project, click 251 **Update** to save the changes. 252 253 ### Configure using declarative setup 254 255 You can specify the key IDs required for signature verification in the project 256 manifest within the `signatureKeys` section, i.e: 257 258 ```yaml 259 apiVersion: argoproj.io/v1alpha1 260 kind: AppProject 261 metadata: 262 name: gpg 263 namespace: argocd 264 spec: 265 clusterResourceWhitelist: 266 - group: '*' 267 kind: '*' 268 description: GnuPG verification 269 destinations: 270 - namespace: '*' 271 server: '*' 272 namespaceResourceWhitelist: 273 - group: '*' 274 kind: '*' 275 signatureKeys: 276 - keyID: 4AEE18F83AFDEB23 277 sourceRepos: 278 - '*' 279 ``` 280 281 `signatureKeys` is an array of `SignatureKey` objects, whose only property is 282 `keyID` at the moment. 283 284 ## Troubleshooting 285 286 ### Disabling the feature 287 288 The GnuPG feature can be completely disabled if desired. In order to disable it, 289 set the environment variable `ARGOCD_GPG_ENABLED` to `false` for the pod 290 templates of the `argocd-server`, `argocd-repo-server`, `argocd-application-controller` 291 and `argocd-applicationset-controller` deployments. 292 293 After the pods have been restarted, the GnuPG feature is disabled. 294 295 ### GnuPG key ring 296 297 The GnuPG key ring used for signature verification is maintained within the 298 pods of `argocd-repo-server`. The keys in the keyring are synchronized to the 299 configuration stored in the `argocd-gpg-keys-cm` ConfigMap resource, which is 300 volume-mounted to the `argocd-repo-server` pods. 301 302 !!!note 303 The GnuPG key ring in the pods is transient and gets recreated from the 304 configuration on each restart of the pods. You should never add or remove 305 keys manually to the key ring, because your changes will be lost. Also, 306 any of the private keys found in the key ring are transient and will be 307 regenerated upon each restart. The private key is only used to build the 308 trust DB for the running pod. 309 310 To check whether the keys are actually in sync, you can `kubectl exec` into the 311 repository server's pods and inspect the key ring, which is located at path 312 `/app/config/gpg/keys` 313 314 ```bash 315 $ kubectl exec -it argocd-repo-server-7d6bdfdf6d-hzqkg bash 316 argocd@argocd-repo-server-7d6bdfdf6d-hzqkg:~$ GNUPGHOME=/app/config/gpg/keys gpg --list-keys 317 /app/config/gpg/keys/pubring.kbx 318 -------------------------------- 319 pub rsa2048 2020-06-15 [SC] [expires: 2020-12-12] 320 D48F075D818A813C436914BC9324F0D2144753B1 321 uid [ultimate] Anon Ymous (ArgoCD key signing key) <noreply@argoproj.io> 322 323 pub rsa2048 2017-08-16 [SC] 324 5DE3E0509C47EA3CF04A42D34AEE18F83AFDEB23 325 uid [ultimate] GitHub (web-flow commit signing) <noreply@github.com> 326 327 argocd@argocd-repo-server-7d6bdfdf6d-hzqkg:~$ 328 ``` 329 330 If the key ring stays out of sync with your configuration after you have added 331 or removed keys for a longer period of time, you might want to restart your 332 `argocd-repo-server` pods. If such a problem persists, please consider raising 333 a bug report.