Ce contenu n'est pas disponible dans la langue sélectionnée.
Chapter 4. Creating and verifying task run signatures without any additional authentication
To verify signatures of task runs by using Tekton Chains with any additional authentication, perform the following tasks:
-
Generate an encrypted
x509orcosignkey pair and store it as a Kubernetes secret. - Configure the Tekton Chains backend storage.
- Create a task run, sign it, and store the signature and the payload as annotations on the task run itself.
- Retrieve the signature and payload from the signed task run.
- Verify the signature of the task run.
Prerequisites
Ensure that you install the following components on the cluster:
- Red Hat OpenShift Pipelines Operator
- Tekton Chains
- Cosign
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