|
| 1 | +--- |
| 2 | +type: docs |
| 3 | +category: Container Registries |
| 4 | +title: OCI and Referrers |
| 5 | +weight: 750 |
| 6 | +--- |
| 7 | + |
| 8 | +Cosign supports the OCI 1.1 specification, which introduces the **referrers API** for discovering artifacts associated with a container image. This page explains how cosign uses the referrers API and how to configure signature and attestation storage modes. |
| 9 | + |
| 10 | +## What is the Referrers API? |
| 11 | + |
| 12 | +The OCI Distribution Specification 1.1 introduced the referrers API as a standardized way to discover artifacts (like signatures, attestations, and SBOMs) associated with a container image. |
| 13 | + |
| 14 | +Instead of relying on tag naming conventions (e.g., `sha256-<digest>.sig`), the referrers API uses a `subject` field in the artifact manifest to create a direct relationship between the artifact and the image it references. Registries that support OCI 1.1 expose a `/referrers/<digest>` endpoint that returns all artifacts linked to a given image digest. |
| 15 | + |
| 16 | +## Valid Format and Storage Combinations |
| 17 | + |
| 18 | +| Bundle Format | Storage Mode | Signatures | Attestations | Notes | |
| 19 | +|--------------|--------------|------------|--------------|-------| |
| 20 | +| New (`--new-bundle-format=true`) | Referrers (OCI 1.1) | Yes | Yes | **Default in cosign 3.0+** | |
| 21 | +| New (`--new-bundle-format=true`) | Tag-based (OCI 1.0) | Yes | Yes | Uses referrers tag fallback (`sha256-<digest>`) | |
| 22 | +| Old (`--new-bundle-format=false`) | Referrers (OCI 1.1) | Yes | No | Signatures only; attestations always use tags | |
| 23 | +| Old (`--new-bundle-format=false`) | Tag-based (OCI 1.0) | Yes | Yes | Legacy mode | |
| 24 | + |
| 25 | +### Key Constraints |
| 26 | + |
| 27 | +1. **Old format requires disabling signing config**: When using `--new-bundle-format=false`, you must also set `--use-signing-config=false`. The default TUF-based signing config requires the new bundle format. |
| 28 | + |
| 29 | +2. **Old format attestations always use tags**: When using `--new-bundle-format=false`, attestations are always stored using tag-based storage, regardless of any `--registry-referrers-mode` flag. |
| 30 | + |
| 31 | +## Scenario 1: New Format + OCI 1.1 Referrers |
| 32 | + |
| 33 | +When using the default new bundle format against a registry that supports the OCI 1.1 specification, cosign will store signatures and attestations using the OCI 1.1 referrers API. |
| 34 | + |
| 35 | +### Signing |
| 36 | + |
| 37 | +```shell |
| 38 | +# Key-based signing |
| 39 | +cosign sign --key cosign.key $IMAGE |
| 40 | + |
| 41 | +# Keyless signing (default) |
| 42 | +cosign sign $IMAGE |
| 43 | +``` |
| 44 | + |
| 45 | +The signature is stored as an OCI 1.1 referrer with the new sigstore bundle format. |
| 46 | + |
| 47 | +### Verification |
| 48 | + |
| 49 | +```shell |
| 50 | +# Key-based verification |
| 51 | +cosign verify --key cosign.pub $IMAGE |
| 52 | + |
| 53 | +# Keyless verification |
| 54 | +cosign verify \ |
| 55 | + --certificate-identity=name@example.com \ |
| 56 | + --certificate-oidc-issuer=https://accounts.example.com \ |
| 57 | + $IMAGE |
| 58 | +``` |
| 59 | + |
| 60 | +### Attestations |
| 61 | + |
| 62 | +```shell |
| 63 | +# Create attestation |
| 64 | +cosign attest \ |
| 65 | + --key cosign.key \ |
| 66 | + --type slsaprovenance \ |
| 67 | + --predicate predicate.json \ |
| 68 | + $IMAGE |
| 69 | + |
| 70 | +# Verify attestation |
| 71 | +cosign verify-attestation \ |
| 72 | + --key cosign.pub \ |
| 73 | + --type slsaprovenance \ |
| 74 | + $IMAGE |
| 75 | +``` |
| 76 | + |
| 77 | +The attestation is stored as an OCI 1.1 referrer. |
| 78 | + |
| 79 | +## Scenario 2: New Format + OCI 1.0 (Referrers Tag Schema Fallback) |
| 80 | + |
| 81 | +When using the default new bundle format against a registry that does not support the OCI 1.1 referrers API, cosign automatically falls back to the **referrers tag schema** defined in the OCI Distribution Specification. Artifacts are stored under a `sha256-<digest>` index tag, and both signing and verification work transparently. |
| 82 | + |
| 83 | +> **Note:** This fallback only works for clients that implement the OCI Distribution Specification 1.1 referrers tag schema. Tools written to look for old-format `.sig` tags will not find new-format signatures stored this way. |
| 84 | +
|
| 85 | +### Signing |
| 86 | + |
| 87 | +```shell |
| 88 | +# Key-based signing |
| 89 | +cosign sign --key cosign.key $IMAGE |
| 90 | + |
| 91 | +# Keyless signing |
| 92 | +cosign sign $IMAGE |
| 93 | +``` |
| 94 | + |
| 95 | +The signature is stored under a `sha256-<digest>` index tag (not a `.sig` tag). |
| 96 | + |
| 97 | +### Verification |
| 98 | + |
| 99 | +```shell |
| 100 | +# Key-based verification |
| 101 | +cosign verify --key cosign.pub $IMAGE |
| 102 | + |
| 103 | +# Keyless verification |
| 104 | +cosign verify \ |
| 105 | + --certificate-identity=name@example.com \ |
| 106 | + --certificate-oidc-issuer=https://accounts.example.com \ |
| 107 | + $IMAGE |
| 108 | +``` |
| 109 | + |
| 110 | +### Attestations |
| 111 | + |
| 112 | +```shell |
| 113 | +# Create attestation |
| 114 | +cosign attest \ |
| 115 | + --key cosign.key \ |
| 116 | + --type slsaprovenance \ |
| 117 | + --predicate predicate.json \ |
| 118 | + $IMAGE |
| 119 | + |
| 120 | +# Verify attestation |
| 121 | +cosign verify-attestation \ |
| 122 | + --key cosign.pub \ |
| 123 | + --type slsaprovenance \ |
| 124 | + $IMAGE |
| 125 | +``` |
| 126 | + |
| 127 | +The attestation is stored under the same `sha256-<digest>` index tag alongside the signature. |
| 128 | + |
| 129 | +## Scenario 3: Old Format + OCI 1.1 Referrers (Signatures Only) |
| 130 | + |
| 131 | +This mode stores signatures using the OCI 1.1 referrers API while using the old bundle format. Note that **attestations are not supported** with OCI 1.1 in this mode, they will fall back to tag-based storage. |
| 132 | + |
| 133 | +### Signing |
| 134 | + |
| 135 | +```shell |
| 136 | +# Requires COSIGN_EXPERIMENTAL=1 environment variable |
| 137 | +COSIGN_EXPERIMENTAL=1 cosign sign \ |
| 138 | + --key cosign.key \ |
| 139 | + --new-bundle-format=false \ |
| 140 | + --use-signing-config=false \ |
| 141 | + --registry-referrers-mode=oci-1-1 \ |
| 142 | + $IMAGE |
| 143 | +``` |
| 144 | + |
| 145 | +The signature is stored as an OCI 1.1 referrer (discoverable via `/referrers/<digest>` endpoint). |
| 146 | + |
| 147 | +### Verification |
| 148 | + |
| 149 | +```shell |
| 150 | +cosign verify \ |
| 151 | + --key cosign.pub \ |
| 152 | + --new-bundle-format=false \ |
| 153 | + --experimental-oci11=true \ |
| 154 | + $IMAGE |
| 155 | +``` |
| 156 | + |
| 157 | +> **Important:** The `--experimental-oci11` flag is required for verification to discover signatures stored via the referrers API. |
| 158 | +
|
| 159 | +## Scenario 4: Old Format + Tag-based (OCI 1.0) |
| 160 | + |
| 161 | +Use this mode with registries that don't support OCI 1.1. |
| 162 | + |
| 163 | +### Signing |
| 164 | + |
| 165 | +```shell |
| 166 | +# With key-based signing (uploads to Rekor transparency log) |
| 167 | +cosign sign --key cosign.key \ |
| 168 | + --new-bundle-format=false \ |
| 169 | + --use-signing-config=false \ |
| 170 | + $IMAGE |
| 171 | + |
| 172 | +# With keyless signing |
| 173 | +cosign sign \ |
| 174 | + --new-bundle-format=false \ |
| 175 | + --use-signing-config=false \ |
| 176 | + $IMAGE |
| 177 | +``` |
| 178 | + |
| 179 | +The signature is stored at a tag: `sha256-<digest>.sig` |
| 180 | + |
| 181 | +### Verification |
| 182 | + |
| 183 | +```shell |
| 184 | +# Key-based verification |
| 185 | +cosign verify --key cosign.pub \ |
| 186 | + --new-bundle-format=false \ |
| 187 | + $IMAGE |
| 188 | + |
| 189 | +# Keyless verification |
| 190 | +cosign verify \ |
| 191 | + --new-bundle-format=false \ |
| 192 | + --certificate-identity=name@example.com \ |
| 193 | + --certificate-oidc-issuer=https://accounts.example.com \ |
| 194 | + $IMAGE |
| 195 | +``` |
| 196 | + |
| 197 | +### Attestations |
| 198 | + |
| 199 | +```shell |
| 200 | +# Create attestation (uploads to Rekor) |
| 201 | +cosign attest \ |
| 202 | + --key cosign.key \ |
| 203 | + --new-bundle-format=false \ |
| 204 | + --use-signing-config=false \ |
| 205 | + --type slsaprovenance \ |
| 206 | + --predicate predicate.json \ |
| 207 | + $IMAGE |
| 208 | + |
| 209 | +# Verify attestation |
| 210 | +cosign verify-attestation \ |
| 211 | + --key cosign.pub \ |
| 212 | + --new-bundle-format=false \ |
| 213 | + --type slsaprovenance \ |
| 214 | + $IMAGE |
| 215 | +``` |
| 216 | + |
| 217 | +The attestation is stored as a tag: `sha256-<digest>.att` |
| 218 | + |
| 219 | + |
| 220 | +## Discovering Referrers |
| 221 | + |
| 222 | +You can discover all artifacts associated with an image using the OCI referrers API: |
| 223 | + |
| 224 | +```shell |
| 225 | +# Using curl |
| 226 | +curl https://registry.example.com/v2/myrepo/referrers/sha256:abc123... |
| 227 | + |
| 228 | +# Using oras |
| 229 | +oras discover registry.example.com/myrepo@sha256:abc123... |
| 230 | +``` |
0 commit comments