# Generating and Verifying Attestations With Witness

Source: https://www.testifysec.com/blog/attestations-with-witness/

Author: TestifySec

Published: 2022-12-09

Updated: 2026-10-06

Learn how to generate and verify attestations to ensure supply chain integrity.

Editorial update · October 6, 2026

Updated by TestifySec Editorial to clarify the trust boundaries and replace incomplete migrated instructions with maintained references. The original publication date and article URL are unchanged.

- [Witness documentation ↗](https://witness.dev/)
- [Current TestifySec docs →](https://www.testifysec.com/docs)
- [Trust architecture →](https://www.testifysec.com/docs/cilock/trust)

A test result is more useful when it is tied to the work it examined. Witness captures observations about a command and packages them into an attestation that a verifier can evaluate later.

 

The original December 2022 tutorial lost several code and policy blocks during a content migration. This revised guide explains the workflow and points to maintained Witness examples. It does not present the missing fragments as a complete, executable tutorial.

 

## Prerequisites

 

Choose a pinned [Witness release](https://github.com/in-toto/witness/releases) and follow the corresponding [Witness documentation](https://witness.dev/). Use an isolated example repository and decide which signing identity the verifier should accept before generating evidence.

 

For keyless signing, follow the [Sigstore tutorial](https://witness.dev/docs/docs/tutorials/sigstore-keyless/). For a managed signing key, consult the [KMS signer documentation](https://witness.dev/docs/docs/signers/kms/). These are Witness workflows. Current CI/lock instructions live in the [shared TestifySec documentation](https://www.testifysec.com/docs/cilock/getting-started/first-attestation).

 

## Generating the attestations

 

Run the build or test through Witness with the attestors required for your decision. Keep the output artifact and the signed attestation together. If a policy requires a generated product, make sure the command actually produces that file in the observed scope; a pre-existing file is not proof of a new build.

 

Capture is limited by the selected attestors and their environment. Recording a command does not imply that every filesystem operation, network request, or external service was observed.

 

## Viewing the attestation

 

Inspect the envelope, its statement, the artifact digests, and the recorded results. Decoding JSON is inspection, not verification. A reader must still validate the signature, expected identity, policy, and artifact binding.

 

## Specifying the Rego constraints

 

A policy can require a successful exit code, an expected artifact, and a scanner result that meets a threshold. A successful exit code alone does not establish useful coverage: a command that does nothing can also return zero.

 

Write the check against the actual predicate schema emitted by your selected release. Include a failing result, a missing predicate, and a mismatched artifact in the verification cases. Rejecting those cases is as important as accepting the intended one.

 

## Creating the Witness policy

 

Specify the required steps, trusted evidence producers, and attestation types. Where certificates are used, constrain the identity and issuer. Observational fields such as environment variables and agent labels must not stand in for an authenticated signer.

 

## Signing the Witness policy

 

Protect the policy separately from build evidence. The policy signer authorizes requirements; the evidence producer reports observations. Use the signing and trust-distribution procedure supported by your pinned Witness release. Do not substitute CI/lock policy commands into a Witness example.

 

## Verifying the attestations

 

Verify the signed policy, the supplied evidence, and the exact artifact that will be accepted. Run verification at an enforced decision point, not as an optional report after deployment.

 

A valid signature detects alteration of the signed statement. It does not make an untrusted producer honest. If an attacker controls both execution and evidence production, a convincing signed record can still be false. The [trust architecture](https://www.testifysec.com/docs/cilock/trust) explains why producer isolation and signing authority matter.

 

## From a tutorial to a working system

 

Witness and [Archivista](https://github.com/in-toto/archivista) support open-source capture, verification, and evidence storage. For the TestifySec product workflow, [CI/lock captures the work](https://www.testifysec.com/docs/cilock/getting-started/first-attestation), [Pushgate checks the push](https://www.testifysec.com/docs/pushgate/trust-architecture), and the platform manages multiple gates and reuses evidence for technical controls. A passing test supports its defined requirement; it is not an authorization or whole-framework compliance result.
