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