-
Notifications
You must be signed in to change notification settings - Fork 105
feat: add documentation for working with OCI 1.0 and OCI 1.1 containe… #411
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,14 @@ | ||
| --- | ||
| type: docs | ||
| title: "Container Registries" | ||
| description: "Documentation for working with container registries" | ||
| lead: "" | ||
| date: 2020-10-06T08:49:15+00:00 | ||
| lastmod: 2020-10-06T08:49:15+00:00 | ||
| draft: false | ||
| images: [] | ||
| weight: 80 | ||
| --- | ||
|
|
||
|
|
||
|
|
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,230 @@ | ||
| --- | ||
| type: docs | ||
| category: Container Registries | ||
| title: OCI and Referrers | ||
| weight: 750 | ||
| --- | ||
|
|
||
| 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. | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I would suggest having an opening section called "Who is this for?" or something similar that gives a preface for who the target audience is for this section. I think this is mainly needed for developers trying to create tooling to examine the bundles that cosign is producing, while most developers just trying to use cosign don't need to be bogged down by this background knowledge. |
||
|
|
||
| ## What is the Referrers API? | ||
|
|
||
| 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. | ||
|
|
||
| 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. | ||
|
|
||
| ## Valid Format and Storage Combinations | ||
|
|
||
| | Bundle Format | Storage Mode | Signatures | Attestations | Notes | | ||
| |--------------|--------------|------------|--------------|-------| | ||
| | New (`--new-bundle-format=true`) | Referrers (OCI 1.1) | Yes | Yes | **Default in cosign 3.0+** | | ||
| | New (`--new-bundle-format=true`) | Tag-based (OCI 1.0) | Yes | Yes | Uses referrers tag fallback (`sha256-<digest>`) | | ||
| | Old (`--new-bundle-format=false`) | Referrers (OCI 1.1) | Yes | No | Signatures only; attestations always use tags | | ||
| | Old (`--new-bundle-format=false`) | Tag-based (OCI 1.0) | Yes | Yes | Legacy mode | | ||
|
|
||
| ### Key Constraints | ||
|
|
||
| 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. | ||
|
|
||
| 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. | ||
|
|
||
| ## Scenario 1: New Format + OCI 1.1 Referrers | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. It might be good to have a brief explanation of what "new format" even means, as someone who is not a cosign developer probably doesn't have that context. |
||
|
|
||
| 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. | ||
|
|
||
| ### Signing | ||
|
|
||
| ```shell | ||
| # Key-based signing | ||
| cosign sign --key cosign.key $IMAGE | ||
|
|
||
| # Keyless signing (default) | ||
| cosign sign $IMAGE | ||
| ``` | ||
|
|
||
| The signature is stored as an OCI 1.1 referrer with the new sigstore bundle format. | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. What do you think about adding a
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I can take a look, I did have something earlier but took them out before submitting because I thought it was diving too deep.
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I guess I'm suggesting it because I still feel like this page is taking a middle ground approach to the point where I'm still not sure who it's for. If it's just meant to be a high-level overview of how to use cosign sign, then the other examples in the other pages already take care of it and this whole page could be removed. If it's meant to be a deeper dive into the underlying mechanics of cosign and OCI, then it should lean in and really show what it's talking about. |
||
|
|
||
| ### Verification | ||
|
|
||
| ```shell | ||
| # Key-based verification | ||
| cosign verify --key cosign.pub $IMAGE | ||
|
|
||
| # Keyless verification | ||
| cosign verify \ | ||
| --certificate-identity=name@example.com \ | ||
| --certificate-oidc-issuer=https://accounts.example.com \ | ||
| $IMAGE | ||
| ``` | ||
|
|
||
| ### Attestations | ||
|
|
||
| ```shell | ||
| # Create attestation | ||
| cosign attest \ | ||
| --key cosign.key \ | ||
| --type slsaprovenance \ | ||
| --predicate predicate.json \ | ||
| $IMAGE | ||
|
|
||
| # Verify attestation | ||
| cosign verify-attestation \ | ||
| --key cosign.pub \ | ||
| --type slsaprovenance \ | ||
| $IMAGE | ||
| ``` | ||
|
|
||
| The attestation is stored as an OCI 1.1 referrer. | ||
|
|
||
| ## Scenario 2: New Format + OCI 1.0 (Referrers Tag Schema Fallback) | ||
|
|
||
| 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. | ||
|
|
||
| > **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. | ||
|
|
||
| ### Signing | ||
|
|
||
| ```shell | ||
| # Key-based signing | ||
| cosign sign --key cosign.key $IMAGE | ||
|
|
||
| # Keyless signing | ||
| cosign sign $IMAGE | ||
| ``` | ||
|
|
||
| The signature is stored under a `sha256-<digest>` index tag (not a `.sig` tag). | ||
|
|
||
| ### Verification | ||
|
|
||
| ```shell | ||
| # Key-based verification | ||
| cosign verify --key cosign.pub $IMAGE | ||
|
|
||
| # Keyless verification | ||
| cosign verify \ | ||
| --certificate-identity=name@example.com \ | ||
| --certificate-oidc-issuer=https://accounts.example.com \ | ||
| $IMAGE | ||
| ``` | ||
|
|
||
| ### Attestations | ||
|
|
||
| ```shell | ||
| # Create attestation | ||
| cosign attest \ | ||
| --key cosign.key \ | ||
| --type slsaprovenance \ | ||
| --predicate predicate.json \ | ||
| $IMAGE | ||
|
|
||
| # Verify attestation | ||
| cosign verify-attestation \ | ||
| --key cosign.pub \ | ||
| --type slsaprovenance \ | ||
| $IMAGE | ||
| ``` | ||
|
|
||
| The attestation is stored under the same `sha256-<digest>` index tag alongside the signature. | ||
|
|
||
| ## Scenario 3: Old Format + OCI 1.1 Referrers (Signatures Only) | ||
|
|
||
| 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. | ||
|
|
||
| ### Signing | ||
|
|
||
| ```shell | ||
| # Requires COSIGN_EXPERIMENTAL=1 environment variable | ||
| COSIGN_EXPERIMENTAL=1 cosign sign \ | ||
| --key cosign.key \ | ||
| --new-bundle-format=false \ | ||
| --use-signing-config=false \ | ||
| --registry-referrers-mode=oci-1-1 \ | ||
| $IMAGE | ||
| ``` | ||
|
|
||
| The signature is stored as an OCI 1.1 referrer (discoverable via `/referrers/<digest>` endpoint). | ||
|
|
||
| ### Verification | ||
|
|
||
| ```shell | ||
| cosign verify \ | ||
| --key cosign.pub \ | ||
| --new-bundle-format=false \ | ||
| --experimental-oci11=true \ | ||
| $IMAGE | ||
| ``` | ||
|
|
||
| > **Important:** The `--experimental-oci11` flag is required for verification to discover signatures stored via the referrers API. | ||
|
|
||
| ## Scenario 4: Old Format + Tag-based (OCI 1.0) | ||
|
|
||
| Use this mode with registries that don't support OCI 1.1. | ||
|
|
||
| ### Signing | ||
|
|
||
| ```shell | ||
| # With key-based signing (uploads to Rekor transparency log) | ||
| cosign sign --key cosign.key \ | ||
| --new-bundle-format=false \ | ||
| --use-signing-config=false \ | ||
| $IMAGE | ||
|
|
||
| # With keyless signing | ||
| cosign sign \ | ||
| --new-bundle-format=false \ | ||
| --use-signing-config=false \ | ||
| $IMAGE | ||
| ``` | ||
|
|
||
| The signature is stored at a tag: `sha256-<digest>.sig` | ||
|
|
||
| ### Verification | ||
|
|
||
| ```shell | ||
| # Key-based verification | ||
| cosign verify --key cosign.pub \ | ||
| --new-bundle-format=false \ | ||
| $IMAGE | ||
|
|
||
| # Keyless verification | ||
| cosign verify \ | ||
| --new-bundle-format=false \ | ||
| --certificate-identity=name@example.com \ | ||
| --certificate-oidc-issuer=https://accounts.example.com \ | ||
| $IMAGE | ||
| ``` | ||
|
|
||
| ### Attestations | ||
|
|
||
| ```shell | ||
| # Create attestation (uploads to Rekor) | ||
| cosign attest \ | ||
| --key cosign.key \ | ||
| --new-bundle-format=false \ | ||
| --use-signing-config=false \ | ||
| --type slsaprovenance \ | ||
| --predicate predicate.json \ | ||
| $IMAGE | ||
|
|
||
| # Verify attestation | ||
| cosign verify-attestation \ | ||
| --key cosign.pub \ | ||
| --new-bundle-format=false \ | ||
| --type slsaprovenance \ | ||
| $IMAGE | ||
| ``` | ||
|
|
||
| The attestation is stored as a tag: `sha256-<digest>.att` | ||
|
|
||
|
|
||
| ## Discovering Referrers | ||
|
|
||
| You can discover all artifacts associated with an image using the OCI referrers API: | ||
|
|
||
| ```shell | ||
| # Using curl | ||
| curl https://registry.example.com/v2/myrepo/referrers/sha256:abc123... | ||
|
|
||
| # Using oras | ||
| oras discover registry.example.com/myrepo@sha256:abc123... | ||
| ``` | ||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks for double checking the tag fallback option and updating the doc.
Taking a step back, I'm wondering who the audience for this page is meant to be? This is pretty in-depth for a user-facing document. In an ideal world (which I admit is not where we are yet), a cosign user shouldn't really have to know what the referrer's API is, it should "just work" (hence the tag fallback - the user may not even know what OCI version their registry supports, and that's fine). The changes you made in the signing and verification docs cover the user-facing issues of the referrer's API really well already.
Where I think a dedicated page like this could be useful is if it went into more depth on using oras or crane to discover and fetch bundles and attestations in ways that cosign doesn't do (or that we want to discourage and deprecate), so that folks using other tooling to examine their attestations have a resource for building their automation around referrers vs tags.
If you don't want to make any other changes, at a minimum I would suggest that the examples for the new bundle format come first and the legacy format come later. I think we want to be encouraging people to always use the new format - but to come here for workarounds if they have older images or older tooling that only support the old format.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
No problem, I'm glad you highlighted it as I had missed this in my tests.
I'm happy to change this in any way that's useful, the PR was only intended to document the current state and to provide some background for those who wanted to understand more. I can switch the examples around, to focus first on the new format, and we can decide what else needs to be documented after that.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@cmurphy I've moved the sections around, otherwise no significant changes. They are now in the order of new > old format and OCI 1.1 > 1.0.