Chapter 4. Create and verify task run signatures without any additional authentication
Create and verify task run signatures using Tekton Chains without additional authentication by generating encryption keys, configuring the backend storage, and validating the signed artifacts.
Prerequisites
- Red Hat OpenShift Pipelines Operator is installed on the cluster.
- Tekton Chains is installed and running.
- Cosign is installed.
Procedure
-
Generate an encrypted
x509orcosignkey pair. For more information about creating a key pair and saving it as a secret, see "Secrets for signing data in Tekton Chains". In the Tekton Chains configuration, disable the Open Container Initiative (OCI) storage, and set the task run storage and format to
tekton. In theTektonConfigcustom resource set the following values:apiVersion: operator.tekton.dev/v1alpha1 kind: TektonConfig metadata: name: config spec: # ... chain: artifacts.oci.storage: "" artifacts.taskrun.format: tekton artifacts.taskrun.storage: tekton # ...For more information about configuring Tekton Chains using the
TektonConfigcustom resource, see "Configuring Tekton Chains".To restart the Tekton Chains controller to apply the modified configuration, enter the following command:
$ oc delete po -n openshift-pipelines -l app=tekton-chains-controllerCreate a task run by entering the following command:
$ oc create -f https://raw.githubusercontent.com/tektoncd/chains/main/examples/taskruns/task-output-image.yaml-fReplace the example URI with the URI or file path pointing to your task run.
Example output
taskrun.tekton.dev/build-push-run-output-image-qbjvh created
Check the status of the steps by entering the following command. Wait until the process finishes.
$ tkn tr describe --lastExample output
[...truncated output...] NAME STATUS ∙ create-dir-builtimage-9467f Completed ∙ git-source-sourcerepo-p2sk8 Completed ∙ build-and-push Completed ∙ echo Completed ∙ image-digest-exporter-xlkn7 CompletedTo retrieve the signature from the object stored as
base64encoded annotations, enter the following commands:$ tkn tr describe --last -o jsonpath="{.metadata.annotations.chains\.tekton\.dev/signature-taskrun-$TASKRUN_UID}" | base64 -d > sig$ export TASKRUN_UID=$(tkn tr describe --last -o jsonpath='{.metadata.uid}')To verify the signature using the public key that you created, enter the following command:
$ cosign verify-blob-attestation --insecure-ignore-tlog --key path/to/cosign.pub --signature sig --type slsaprovenance --check-claims=false /dev/null--insecure-ignore-tlogReplace
path/to/cosign.pubwith the path name of the public key file.Example output
Verified OK
Verification
Verify that the task run signature is successfully verified:
The output displays
Verified OKwhen the signature matches the public key and the attestation is valid.