Sub topic 13
Operational practices: key rotation, failure modes and troubleshooting
This chapter covers what happens after the first successful cosign verify: keeping keys healthy, knowing how signing and verification break, and diagnosing those breaks quickly. It assumes you have read the earlier chapters on digests, key-based and keyless signing, Rekor, and admission policies. You should be comfortable with the cosign sign and cosign verify commands, and with reading a registry error message.
Plan for rotation before you need it
A signing setup works on day one. Problems show up when a key expires, a person leaves, or a CI identity changes. Decide the rotation process in advance, because rotating in a hurry during an incident is where mistakes happen.
The three signing modes rotate differently:
| Mode | What rotates | Who or what rotates it | Effort |
|---|---|---|---|
| Local key file | The key pair itself | You, manually | High |
| KMS-backed key | A key version in the KMS | The KMS, or you | Medium |
| Keyless | Certificates (every signing) and the Sigstore trust root | Sigstore, via TUF | Low for you |
Keyless signing has the smallest rotation burden. Each Fulcio certificate lives for about ten minutes, so there is no long-lived secret to rotate. What you maintain instead is the list of identities you trust in your verification commands and policies.
Rotating a key pair
Cosign has no revocation list for key-based signatures. A public key either is or is not in your verifier's configuration. Rotation therefore means changing what verifiers trust, in this order:
- Generate a new key pair.
- Add the new public key to verifiers, alongside the old one.
- Switch CI to sign new images with the new private key.
- Re-sign images that must stay deployable with the new key.
- Remove the old public key from verifiers once nothing depends on it.
Verifiers must trust both keys during the overlap. Otherwise, either new images fail verification or old running workloads cannot be rescheduled.
# 1. New key pair with a distinct name
COSIGN_PASSWORD="$NEW_KEY_PASSWORD" cosign generate-key-pair
mv cosign.key cosign-2026.key
mv cosign.pub cosign-2026.pub
# 2. Add a second signature to an image that is already signed with the old key
COSIGN_PASSWORD="$NEW_KEY_PASSWORD" cosign sign --yes --key cosign-2026.key "$IMAGE"
# 3. Both keys now verify the same digest
cosign verify --key cosign-2025.pub "$IMAGE" > /dev/null && echo "old key ok"
cosign verify --key cosign-2026.pub "$IMAGE" > /dev/null && echo "new key ok"Signing the same digest again does not replace the old signature. Cosign appends another signature to the same signature artifact, so the image carries both. Each cosign verify --key call succeeds if at least one signature matches that key.
Name key files with the year or a key ID. When a verification fails at 3 a.m., "which key signed this?" should be answerable from a file name.
If a key is compromised
Rotation from compromise is different from routine rotation. The attacker can sign anything the old key could sign, and there is no revocation list. The response is:
- Remove the old public key from every verifier and policy right away, accepting that old images will fail.
- Generate a new key pair and store the private key somewhere stronger than before.
- Rebuild and re-sign images from known-good source. Do not just re-sign existing digests, because you cannot be sure which of them an attacker pushed.
- Review registry push logs for the compromise window.
Rekor does not stop this attack for key-based signatures, because the attacker can upload entries too. It does give you timestamps to bound the window.
Failure modes
Most outages in a signing pipeline come from a short list of causes. Knowing them lets you tell "the image is bad" from "the plumbing is broken".
Dependencies that can be down
Keyless signing needs several services at signing time: the OIDC provider, Fulcio, and Rekor. Verification needs the signature in your registry, and normally access to Rekor and the TUF root. If any of these is unreachable, the related step fails. Whether you fail open or closed is your decision, and you should make it explicitly.
- Signing fails when Fulcio or Rekor is down. Cosign refuses to produce a keyless signature without a log entry. Retry in the pipeline, and do not skip signing to unblock a release.
- Verification fails when Rekor is unreachable. By default, Cosign checks the transparency log. You can verify offline using the signed entry timestamp stored with the signature, but only if the signature was created with that bundle.
- Admission fails when the registry or Rekor is slow. A cluster policy that verifies on every pod creation turns registry latency into scheduling failures.
Signatures that go missing
A signature is an artifact in a registry, so ordinary registry operations can lose it:
- Copying only the image.
docker pullfollowed bydocker pushto another registry copies the image but not its signature. Usecosign copy SRC DSTorcrane copycarefully, then verify at the destination. - Garbage collection and retention rules. Cleanup policies that delete untagged manifests or old tags can remove the signature tag while the image remains. Exempt tags that look like
sha256-<digest>.sig. - Signing the wrong digest. A multi-architecture image has an index digest and one digest per platform. If you sign a platform manifest but deploy by the index digest, verification finds nothing. Sign and verify the same digest you deploy.
Verification that passes for the wrong reason
A passing check proves less than people assume. These are the common ways it gets weaker:
- Verifying by tag. A tag can point to a different digest later. Resolve the digest first and verify that.
- Loose identity matching. Using a regular expression such as
--certificate-identity-regexp '.*'accepts any signer. Match the exact workflow path and ref where you can. - Skipping the log.
--insecure-ignore-tlogremoves the proof that a certificate was valid when it was used. Never use it in production gates.
Troubleshooting workflow
Work from the outside in: does the signature exist, is it for this digest, and who signed it? The diagram shows the order I use.
Inspect what is actually in the registry
Start with the tools that show you the registry's state, not your assumptions:
# Where would Cosign look for the signature?
cosign triangulate "$IMAGE"
# List signatures, attestations and SBOMs attached to the image
cosign tree "$IMAGE"
# Print the verification result as JSON, including the certificate subject
cosign verify \
--certificate-identity "$EXPECTED_IDENTITY" \
--certificate-oidc-issuer "$EXPECTED_ISSUER" \
"$IMAGE" | jq '.[0].optional'If cosign tree shows no signatures, the problem is upstream of verification. If it shows signatures but verification says none match, the signer or key differs from what you expect.
Common errors and their usual causes
| Symptom | Likely cause | What to do |
|---|---|---|
| `no signatures found` or `no matching signatures` | Signature missing, signed a different digest, or signed with a different key | Run `cosign tree` and `cosign triangulate`. Confirm the digest matches the deployed one. |
| `none of the expected identities matched what was in the certificate` | Wrong `--certificate-identity`, or the workflow file, branch or ref changed | Print the certificate subject from the `verify` JSON and compare it to your expected string. |
| Issuer mismatch | Signed by a different OIDC provider than expected, such as a laptop login instead of CI | Check `--certificate-oidc-issuer`. For GitHub Actions use `https://token.actions.githubusercontent.com`. |
| `UNAUTHORIZED` when signing | CI token lacks write permission to the registry | Grant `packages: write` or the registry equivalent. Signatures are pushed to the same repository. |
| `getting ID Token` or OIDC errors in CI | Missing `id-token: write` permission | Add the permission to the job. |
| `unable to decrypt` or password errors | Wrong key password | Set `COSIGN_PASSWORD` correctly, or use a KMS key. |
| Rekor timeouts or 5xx responses | Transparency log outage or network egress rules | Retry with backoff. Check egress to Rekor and Fulcio. |
| Tuf or trust root errors | Stale local trust root | Run `cosign initialize` to refresh it. |
| Certificate is expired | Verifier cannot find proof of the signing time | Make sure the Rekor entry or bundle is available, and do not skip the log. |
The certificate-expired case surprises people. A Fulcio certificate is valid for minutes, so every keyless signature has an expired certificate by the time anyone verifies it. Verification is correct as long as the Rekor entry proves the signing happened inside the validity window. If that proof is missing, verification fails.
Check the environment
Several failures come from the machine running Cosign, not from the image:
- Clock skew. OIDC tokens and certificates have short lifetimes. A runner or laptop clock off by several minutes can cause token or timestamp errors.
- Version differences. Cosign 2.x requires identity and issuer flags for keyless verification and stores signatures in a newer bundle format. Pin the Cosign version in CI and in policy controllers, and read the release notes before upgrading.
- Private Sigstore deployments. If you run your own Fulcio and Rekor, verifiers need the matching root and URLs. Public defaults will not trust your certificates.
A short operations checklist
- Verify and sign by digest only, in every script and policy.
- Keep a record of which identities and keys are trusted, and review it whenever people or workflows change.
- Test verification from a clean machine on a schedule, so you notice missing signatures before an incident does.
- Exempt signature tags from registry cleanup.
- Pin Cosign versions and upgrade deliberately.
- Decide whether admission fails open or closed, and write down who can override it.
Exercise
A team rotated to a new key pair and updated CI to sign with it. Two days later, pods running images from before the rotation fail to start after a node restart. The admission policy lists only the new public key. What went wrong, and what is a safe fix?
Show answer
The policy dropped the old public key before the older images had a signature from the new key, so those images no longer verify. A safe fix is to add the old public key back to the policy during an overlap period, re-sign the images that still need to run with the new key (signing the same digest appends a second signature), and remove the old key once nothing depends on it.
Exercise
cosign verify fails with "no matching signatures" for registry.example.com/app:1.4, but the CI log says signing succeeded. List three checks you would make, in order.
Show answer
First, resolve the tag to its current digest and verify by digest, since the tag may now point to a different image than the one signed. Second, run cosign tree and cosign triangulate on that digest to see whether a signature exists in the registry, which would reveal a missing signature from a copy or garbage collection. Third, compare the signer to your expectation: the key used for verification, or the certificate identity and issuer for keyless signing.
Exercise
Why does a keyless signature still verify successfully long after its Fulcio certificate expired?
Show answer
The Rekor transparency log entry (or the bundle derived from it) carries a signed timestamp showing that the signature was created while the certificate was valid. Verification checks that the certificate was valid at that logged time, not at the present time.