2023-08-02 13:58:34 -05:00
# Image Trust
The `imagetrust` extension provides a mechanism to verify image signatures using certificates and public keys
2023-07-06 06:57:59 -05:00
## How to configure zot for verifying signatures
2023-08-02 13:58:34 -05:00
In order to configure zot for verifying signatures, the user should first enable this feature:
```json
"extensions": {
"trust": {
"enable": true,
"cosign": true,
"notation": true
}
}
```
In order for verification to run, the user needs to enable at least one of the cosign or notation options above.
## Uploading public keys or certificates
Next the user needs to upload the keys or certificates used for the verification.
| Supported queries | Input | Output | Description |
| --- | --- | --- | --- |
| Upload a certificate | certificate | None | Add certificate for verifying notation signatures|
| Upload a public key | public key | None | Add public key for verifying cosign signatures |
### Uploading a Cosign public key
2023-07-06 06:57:59 -05:00
2023-08-02 13:58:34 -05:00
The Cosign public keys uploaded correspond to the private keys used to sign images with `cosign` .
2023-07-06 06:57:59 -05:00
2023-08-02 13:58:34 -05:00
***Example of request***
2023-07-06 06:57:59 -05:00
2023-08-02 13:58:34 -05:00
```bash
curl --data-binary @file .pub -X POST "http://localhost:8080/v2/_zot/ext/cosign
```
As a result of this request, the uploaded file will be stored in `_cosign` directory
2023-09-08 02:03:58 -05:00
under the rootDir specified in the zot config or in Secrets Manager.
2023-07-06 06:57:59 -05:00
2023-08-02 13:58:34 -05:00
### Uploading a Notation certificate
2023-07-06 06:57:59 -05:00
2023-08-02 13:58:34 -05:00
Notation certificates are used to sign images with the `notation` tool.
The user needs to specify the type of the truststore through the `truststoreType`
2023-09-08 02:03:58 -05:00
query parameter.
`truststoreType` defaults to `ca` .
2023-07-06 06:57:59 -05:00
2023-08-02 13:58:34 -05:00
***Example of request***
2023-07-06 06:57:59 -05:00
2023-08-02 13:58:34 -05:00
```bash
2023-09-08 02:03:58 -05:00
curl --data-binary @certificate .crt -X POST "http://localhost:8080/v2/_zot/ext/notation?truststoreType=ca"
2023-08-02 13:58:34 -05:00
```
2023-07-06 06:57:59 -05:00
2023-09-08 02:03:58 -05:00
As a result of this request, the uploaded file will be stored in `_notation/truststore/x509/{truststoreType}/default`
directory under the rootDir specified in the zot config or in Secrets Manager.
2023-07-06 06:57:59 -05:00
2023-08-02 13:58:34 -05:00
## Verification and results
2023-07-06 06:57:59 -05:00
2023-08-02 13:58:34 -05:00
Based on the uploaded files, signatures verification will be performed for all the signed images.
The information determined about the signatures will be:
2023-07-06 06:57:59 -05:00
- the tool used to generate the signature (`cosign` or `notation` )
- info about the trustworthiness of the signature (if there is a certificate or a public key which can successfully verify the signature)
- the author of the signature which will be:
2023-08-02 13:58:34 -05:00
- the public key -> for signatures generated using `cosign`
- the subject of the certificate -> for signatures generated using `notation`
The information above will be included in the ManifestSummary objects returned by the `search` extension.
***Example of GraphQL output***
2023-07-06 06:57:59 -05:00
```json
{
"data": {
"Image": {
"Manifests": [
{
"Digest":"sha256:6c19fba547b87bde9a45df2f8563e0c61826d098dd30192a2c8b86da1e1a6360"
}
],
"IsSigned": true,
"Tag": "latest",
"SignatureInfo":[
{
"Tool":"cosign",
"IsTrusted":false,
"Author":""
},
{
"Tool":"cosign",
"IsTrusted":false,
"Author":""
},
{
"Tool":"cosign",
"IsTrusted": true,
"Author":"-----BEGIN PUBLIC KEY-----\nMFkwEwYHKoZIzj0CAQYIKoZIzj0DAQcDQgAE9pN+/hGcFlh4YYaNvZxNvuh8Qyhl\npURz77qScOHe3DqdmiWiuqIseyhEdjEDwpL6fHRwu3a2Nd9wbKqm0la76w==\n-----END PUBLIC KEY-----\n"
},
{
"Tool":"notation",
"IsTrusted": false,
"Author":"CN=v4-test,O=Notary,L=Seattle,ST=WA,C=US"
},
{
"Tool":"notation",
"IsTrusted": true,
"Author":"CN=multipleSig,O=Notary,L=Seattle,ST=WA,C=US"
}
]
}
}
}
```
## Notes
2023-09-08 02:03:58 -05:00
- The files (public keys and certificates) uploaded using the exposed routes will be stored in some specific directories called `_cosign` and `_notation` under `$rootDir` in case of local filesystem or in Secrets Manager in case of cloud.
2023-08-02 13:58:34 -05:00
2023-07-06 06:57:59 -05:00
- `_cosign` directory will contain the uploaded public keys
2023-08-02 13:58:34 -05:00
2023-07-06 06:57:59 -05:00
```
_cosign
├── $publicKey1
2023-08-02 13:58:34 -05:00
└── $publicKey2
2023-07-06 06:57:59 -05:00
```
- `_notation` directory will have this structure:
```
_notation
├── trustpolicy.json
2023-08-02 13:58:34 -05:00
└── truststore
└── x509
└── $truststoreType
2023-09-08 02:03:58 -05:00
└── default
2023-08-02 13:58:34 -05:00
└── $certificate
2023-07-06 06:57:59 -05:00
```
2023-09-08 02:03:58 -05:00
where `trustpolicy.json` file has this default content which can not be modified by the user:
2023-08-02 13:58:34 -05:00
```json
2023-07-06 06:57:59 -05:00
{
"version": "1.0",
"trustPolicies": [
{
"name": "default-config",
"registryScopes": [ "*" ],
"signatureVerification": {
"level" : "strict"
},
2023-09-08 02:03:58 -05:00
"trustStores": ["ca:default","signingAuthority:default"],
2023-07-06 06:57:59 -05:00
"trustedIdentities": [
"*"
]
}
]
2023-08-02 13:58:34 -05:00
}
2023-07-06 06:57:59 -05:00
```