CICD-187 · Verify signed container policy with cosign
Encyclopedia · Workflow security fundamentals · All snippets
Previous · CICD-186 · Next · CICD-188
1. Where it fits
- Placement Bash run step following checkout, or equivalent lab terminal.
- Prerequisites trusted repository, verified inputs and read-only default access.
- Platforms local-linux, github-actions, gitea-actions.
- Parameters
EXPECTED_IDENTITY,IMAGE_REF.
2. Copy the snippet
bash
cosign verify --certificate-identity "${EXPECTED_IDENTITY:?}" --certificate-oidc-issuer https://token.actions.githubusercontent.com "${IMAGE_REF:?}"3. How it works
Cosign checks the signed image and constrains the certificate issuer and identity. Specify the exact trusted workflow identity so a signature from another signer cannot satisfy the rule.
4. Verify the result
Require the release workflow's exact signer identity and immutable candidate reference.
Watch for. Use the intended trusted execution context. Keep secret values out of traces, artifacts and debug output.
Validation syntax-validated (Bash parse). Status definitions.