Sub topic 6
Keyless signing: OIDC identity and short-lived certificates
This chapter assumes you can build and push an image, that you know what a key pair and a signature are, and that you have run cosign sign --key from the previous chapter. Here you will see how Cosign signs an image without a long-lived private key, what actually gets stored, and what the signature does and does not prove.
The problem keyless signing solves
Key-based signing moves the trust problem into key management. The private key file must be stored, backed up, rotated and kept out of logs. Anyone who copies it can sign as you, and verifiers must obtain and trust the matching public key through some other channel.
Keyless signing replaces the long-lived key with an identity. You prove who you are to an identity provider, and a certificate authority issues a certificate that binds a short-lived public key to that identity. The private key exists only for the duration of one signing operation and is then discarded. "Keyless" refers to the user's experience: keys still exist, but you never store or manage them.
The moving parts
Three services cooperate during a keyless signature.
| Component | Role |
|---|---|
| OIDC provider | Authenticates you or your CI job and issues an ID token (a signed JWT) that states your identity. Examples are Google, GitHub, Microsoft and GitHub Actions. |
| Fulcio | The Sigstore certificate authority. It validates the ID token and issues a code-signing certificate valid for about ten minutes. |
| Rekor | The transparency log. It records the signature and certificate so that the signing event can be checked later. The next chapter covers it in detail. |
OIDC (OpenID Connect) is an identity layer on top of OAuth 2.0. The important output for this chapter is the ID token. It contains claims such as iss (the issuer), sub (the subject) and, for many providers, email. Fulcio copies the relevant claims into the certificate it issues.
The signing flow step by step
In order:
- Cosign generates an ephemeral key pair in memory.
- Cosign obtains an ID token. Interactively, it opens a browser login. In CI, it can use a token the platform provides.
- Cosign sends Fulcio the ID token, the new public key, and a signature over the token's subject made with the new private key. This proves you hold the private key matching the public key.
- Fulcio checks the token against the provider and returns a certificate. The certificate contains the public key, the identity, and the issuer.
- Cosign signs the image digest with the private key.
- Cosign uploads the signature and certificate to Rekor and receives proof of inclusion.
- Cosign pushes the signature, certificate and log proof to the registry next to the image. Then it discards the private key.
Signing interactively
Resolve the digest first, as shown in the earlier chapter, and sign by digest.
# Resolve the digest of the pushed image
docker buildx imagetools inspect registry.example.com/team/app:1.0.0 --format '{{json .Manifest.Digest}}'
# Always sign and verify by digest, not by tag
IMAGE=registry.example.com/team/app@sha256:<digest>
# Keyless signing: opens an OIDC login in the browser, no key file needed
cosign sign "$IMAGE"Replace <digest> with the value printed by the first command. Cosign 2.x asks you to confirm that the identity and the signing event will be recorded in a public log. In scripts, pass --yes to skip the prompt.
After you log in, the browser shows a success page and Cosign prints the log entry index. No cosign.key file is created.
What the certificate contains
The Fulcio certificate is an X.509 certificate. Two parts matter for verification.
- The subject alternative name (SAN) holds the identity. For a person it is an email address. For a CI job it is a URL that points to the workflow.
- A custom extension holds the OIDC issuer URL, for example
https://accounts.google.com.
Fulcio also writes other claims into extensions for some issuers. GitHub Actions certificates include the repository, the commit SHA, the trigger event and the workflow reference. You can view a certificate by decoding it from the verification output:
cosign verify \
--certificate-identity [email protected] \
--certificate-oidc-issuer https://accounts.google.com \
"$IMAGE" | jq '.[0].optional'The optional object lists the issuer and subject that Cosign extracted from the certificate. Inspect it when a verification fails and you need to see what identity was actually used.
Verifying a keyless signature
Verification needs two facts from you: who you expect the signer to be, and which provider vouched for them.
# Verify by pinning the expected signer identity and OIDC issuer
cosign verify \
--certificate-identity [email protected] \
--certificate-oidc-issuer https://accounts.google.com \
"$IMAGE"Cosign then performs these checks:
- It downloads the signature, certificate and log proof from the registry.
- It checks that the certificate chains to the Fulcio root, which Cosign obtains from the Sigstore trust root.
- It checks that the certificate identity and issuer equal the values you supplied.
- It checks the signature over the image digest using the public key in the certificate.
- It checks the Rekor inclusion proof, which shows the signature was logged while the certificate was still valid.
Step 5 is what lets verification succeed after the ten-minute certificate has expired. The log entry carries a trusted timestamp, so the verifier can tell that the signature was made inside the certificate's validity window.
Exact match versus regular expression
--certificate-identity and --certificate-oidc-issuer require exact string matches. When the identity varies, such as a workflow on any release branch, use the regular expression forms.
cosign verify \
--certificate-identity-regexp '^https://github\.com/OWNER/REPO/\.github/workflows/build\.yml@refs/heads/(main|release/.*)$' \
--certificate-oidc-issuer https://token.actions.githubusercontent.com \
"$IMAGE"Anchor the expression with ^ and $ and escape dots. An unanchored pattern such as github.com/OWNER/REPO also matches github.com/OWNER/REPO-evil and many other strings, which defeats the check.
What keyless signing proves
A successful verification with a pinned identity establishes these facts:
- The image content with this digest was signed by a holder of the pinned identity at the pinned issuer.
- The signature was created while a valid certificate existed, and the event is in a public log.
It does not establish these:
- That the image is free of vulnerabilities or malicious code. A trusted signer can sign a bad image.
- That the signer's account was not compromised. Stolen credentials produce a valid signature.
- That the build was reproducible or came from the source you expect, unless the identity names a specific workflow and you trust that workflow.
Privacy and visibility
Keyless signing on the public Sigstore instance writes the signer's identity to a public log. Email addresses of individuals appear there permanently. Teams that cannot accept this have two options: use CI workload identities, which expose a workflow URL and not a personal email, or run a private Sigstore deployment with its own Fulcio and Rekor. A private deployment is a significant operational commitment, and you must then point Cosign at it with the matching URLs and trust root.
Common errors
| Symptom | Likely cause | Fix |
|---|---|---|
| `no matching signatures` | Signed a different digest than you are verifying, or signed a tag that has since moved. | Resolve the digest again and verify the one that was signed. |
| `expected identity ... does not match` | The certificate contains a different SAN than you pinned, for example a different email or a different workflow ref. | Inspect the `optional` output of a verification and compare it to your flags. |
| `expected issuer ... does not match` | Wrong issuer URL. Google, GitHub login and GitHub Actions use different issuers. | Use `https://token.actions.githubusercontent.com` for Actions tokens. |
| Verification fails in an air-gapped environment | Cosign cannot fetch the trust root or reach Rekor. | Distribute the trust root offline and follow the offline verification options in the Cosign documentation. |
| Browser login does not open | Headless machine. | Use a device flow where supported, or sign from CI with an ambient token. |
| `--certificate-identity` is required | Newer Cosign versions refuse keyless verification without an identity. | Supply identity and issuer flags. Do not work around this. |
Choosing between keyless and keys
Keyless signing suits teams that can accept a public log, that sign mostly from CI, and that want to avoid key storage. It ties trust to identities that the organization already manages. Key-based signing fits environments without internet access to Sigstore services, and cases where a policy requires a specific key held in a KMS or hardware module. A later chapter covers KMS keys.
Exercise
A teammate runs cosign verify --certificate-oidc-issuer https://accounts.google.com "$IMAGE" and reports success. Why is this result weak evidence, and what flag should be added? Also, why can the check still pass an hour after signing, although the certificate lasts only about ten minutes?
Show answer
Without a pinned identity, any person with a Google account can obtain a Fulcio certificate and sign, so the check only proves that someone signed. Add --certificate-identity (or --certificate-identity-regexp) with the expected signer, such as [email protected]. The check passes after the certificate expires because the Rekor entry carries a trusted timestamp showing the signature was made while the certificate was valid.
Exercise
You verify images signed by a GitHub Actions workflow. Which OIDC issuer URL do you pass, and why is --certificate-identity-regexp 'github.com/OWNER/REPO' a poor pattern?
Show answer
Pass https://token.actions.githubusercontent.com. The pattern is unanchored and unescaped, so it also matches identities such as github.com/OWNER/REPO-evil or any string containing it. Anchor it with ^ and $, escape dots, and include the workflow path and ref.