Skip to content

Commit 5c30a41

Browse files
committed
feat: add documentation for working with OCI 1.0 and OCI 1.1 container registries
Signed-off-by: Kevin Conner <kev.conner@gmail.com>
1 parent b5c91a0 commit 5c30a41

4 files changed

Lines changed: 358 additions & 4 deletions

File tree

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
---
2+
type: docs
3+
title: "Container Registries"
4+
description: "Documentation for working with container registries"
5+
lead: ""
6+
date: 2020-10-06T08:49:15+00:00
7+
lastmod: 2020-10-06T08:49:15+00:00
8+
draft: false
9+
images: []
10+
weight: 80
11+
---
12+
13+
14+
Lines changed: 230 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,230 @@
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+
```

content/en/cosign/signing/signing_with_containers.md

Lines changed: 87 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -299,17 +299,53 @@ $ cosign generate $IMAGE | openssl... | cosign attach signature --signature - $I
299299
Pushing signature to: user/demo:sha256-87ef60f558bad79beea6425a3b28989f01dd417164150ab3baab98dcbf04def.sig
300300
```
301301

302-
## Signature location and management
302+
## Container registry storage options
303303

304-
Signatures are uploaded to an OCI artifact stored with a predictable name.
305-
This name can be located with the `cosign triangulate` command:
304+
Cosign supports two options for storing and discovering signatures in container registries:
305+
306+
- **Referrers API (OCI 1.1)**: Signatures are linked to images via the `subject` field in the artifact manifest, enabling discovery through the container registry's referrers API. This is the default in cosign 3.0+. On registries without OCI 1.1 support, cosign will automatically fall back to the referrers tag schema.
307+
- **Tag-based (OCI 1.0)**: Signatures are stored as separate images with a predictable tag name: `sha256-<digest>.sig`. Use this when you need compatibility with older tooling that does not implement the OCI 1.1 referrers tag schema.
308+
309+
For more information about cosign's support for OCI and the referrers API, see [OCI and Referrers]({{< relref "cosign/container_registry/oci_referrers">}}).
310+
311+
## Signing with OCI 1.1 (default)
312+
313+
In cosign 3.0+, the default behavior uses the new bundle format which stores signatures via the OCI 1.1 referrers API:
314+
315+
```shell
316+
$ cosign sign $IMAGE
317+
```
318+
319+
## New format on OCI 1.0 registries
320+
321+
When signing with the 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. The signature is stored under a `sha256-<digest>` tag (an OCI image index listing all referrers), and signing and verification will both work transparently.
322+
323+
> **Note:** This fallback is only available to clients that implement the OCI 1.1 referrers tag schema. Tools written to look for old-format `.sig` tags will not find new-format signatures stored this way.
324+
325+
## Signing with OCI 1.0 (tag-based)
326+
327+
To explicitly use the old bundle format with tag-based storage (i.e. for maximum compatibility with older tooling):
328+
329+
```shell
330+
$ cosign sign --new-bundle-format=false --use-signing-config=false $IMAGE
331+
```
332+
333+
The signature is stored at a tag (`sha256-<digest>.sig`).
334+
335+
> **Note:** The `--use-signing-config=false` flag is required when using `--new-bundle-format=false`. The default signing config (from TUF) requires the new bundle format, so it must be disabled for old format signing.
336+
337+
### Locating signatures
338+
339+
Use the `cosign triangulate` command to find the signature tag:
306340

307341
```shell
308342
$ cosign triangulate $IMAGE
309343
index.docker.io/user/demo:sha256-87ef60f558bad79beea6425a3b28989f01dd417164150ab3baab98dcbf04def8.sig
310344
```
311345

312-
They can be reviewed with `crane`:
346+
### Inspecting the signature manifest
347+
348+
The signature manifest can be reviewed with `crane`:
313349

314350
```shell
315351
$ crane manifest $(cosign triangulate $IMAGE) | jq .
@@ -347,3 +383,50 @@ Some registries support deletion too (DockerHub does not):
347383
```shell
348384
$ cosign clean $IMAGE
349385
```
386+
387+
## Discovering OCI 1.1 signatures
388+
389+
With OCI 1.1 (the default in cosign 3.0+), signatures are linked to the image via the `subject` field and discovered through the referrers API. Use [ORAS](https://oras.land/) to list all artifacts referencing an image:
390+
391+
```shell
392+
$ oras discover $IMAGE
393+
<image>@sha256:1882fa4569e0c591ea092d3766c4893e19b8901a8e649de7067188aba3cc0679
394+
├── application/vnd.dev.cosign.artifact.sig.v1+json
395+
│ └── sha256:441a6e4fcf6131ea979df3ec34c141f55eb5c371e7e81bc90860e460eecaa5fb
396+
└── application/vnd.dev.sigstore.bundle.v0.3+json
397+
└── sha256:9a8458d9d9dda45bdf230e901eeb9695ec3c64c3750f76ee7beab59c0978193c
398+
```
399+
400+
### Inspecting the signature manifest
401+
402+
Retrieve the signature manifest using the referrers endpoint or `oras`:
403+
404+
```shell
405+
$ oras manifest fetch $REGISTRY/$REPO@sha256:441a6e4fcf6131ea979df3ec34c141f55eb5c371e7e81bc90860e460eecaa5fb | jq .
406+
{
407+
"schemaVersion": 2,
408+
"mediaType": "application/vnd.oci.image.manifest.v1+json",
409+
"config": {
410+
"mediaType": "application/vnd.dev.cosign.artifact.sig.v1+json",
411+
"size": 233,
412+
"digest": "sha256:da96469741fd76728fb29c10514f722ea0c38c0a275d30b38231591216c0f99e"
413+
},
414+
"layers": [
415+
{
416+
"mediaType": "application/vnd.dev.cosign.simplesigning.v1+json",
417+
"size": 242,
418+
"digest": "sha256:4af22300d43719854f07d484efbfbabd4c31f5e7cbd0362cd1a8f9ec4c0f052c",
419+
"annotations": {
420+
"dev.cosignproject.cosign/signature": "MEYCIQDIg1nynEQPoxYS77beWo0iRn2V8oJg2RaNJzVA/YR3cAIhAOATaFrEonE2r7eUVS2fJStPOWO00InIruhsXHcvw1OT"
421+
}
422+
}
423+
],
424+
"subject": {
425+
"mediaType": "application/vnd.oci.image.manifest.v1+json",
426+
"size": 1022,
427+
"digest": "sha256:1882fa4569e0c591ea092d3766c4893e19b8901a8e649de7067188aba3cc0679"
428+
}
429+
}
430+
```
431+
432+
The `subject` field links the signature back to the original image.

content/en/cosign/verifying/verify.md

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -240,6 +240,33 @@ AcxvLtLEgRjRI4TKnMAXtIGp8K4X4CTWPEXMqSYZZUa2I1YvHyLLY2bEzA==
240240
-----END PUBLIC KEY-----
241241
```
242242

243+
## Container registry discovery options
244+
245+
Cosign can discover signatures stored in a container registry using two options:
246+
247+
1. **Referrers API (OCI 1.1)**: Queries the container registry's referrers endpoint to find linked artifacts.
248+
2. **Tag-based (OCI 1.0)**: Looks for signatures stored with predictable tags like `sha256-<digest>.sig`
249+
250+
### Default verification
251+
252+
By default (cosign 3.0+), verification first checks for OCI 1.1 signatures via the referrers API, then falls back to tag-based discovery for OCI 1.0 signatures:
253+
254+
```shell
255+
cosign verify $IMAGE \
256+
--certificate-identity=... --certificate-oidc-issuer=...
257+
```
258+
259+
### Force OCI 1.0 discovery
260+
261+
To skip the OCI 1.1 referrers check and use only the OCI 1.0 tag-based discovery:
262+
263+
```shell
264+
cosign verify --new-bundle-format=false $IMAGE \
265+
--certificate-identity=... --certificate-oidc-issuer=...
266+
```
267+
268+
For more information about cosign's support for OCI and the referrers API, see [OCI and Referrers]({{< relref "cosign/container_registry/oci_referrers">}}).
269+
243270
## Custom Components
244271

245272
For configuring Cosign to work with custom components, checkout the [Configuring Cosign with Custom Components]({{< relref "cosign/system_config/custom_components">}}) docs to find out how to achieve this.

0 commit comments

Comments
 (0)