thephpf / attestation
A PHP library to aid in verifying artifact attestations
0.0.8
2026-09-13 19:02 UTC
Requires
- php: ^8.0
- ext-json: *
- composer/composer: ^2.2
- symfony/console: ^5.4 || ^6.0 || ^7.0 || ^8.0
- webmozart/assert: ^1.11 || ^2.0
Requires (Dev)
- doctrine/coding-standard: ^13.0 || ^14.0
- phpstan/phpstan: ^2.1
- phpstan/phpstan-webmozart-assert: ^2.0
- phpunit/phpunit: ^9.6.25
Suggests
- ext-bcmath: Needed to verify message-signature bundles when only a digest, not the real artifact, is available (used if ext-gmp is not present)
- ext-gmp: Preferred over ext-bcmath for verifying message-signature bundles from a digest alone; consistently fast regardless of PHP version
- ext-openssl: Needed to verify certificates using OpenSSL
- ext-snappy: Decompress bundle attestations faster; if not, flow-php/snappy PHP fallback is used
- ext-sodium: Needed to verify Ed25519 transparency log signatures
Provides
None
Conflicts
None
Replaces
None
README
A PHP library to aid in verifying artifact attestations. This tool will carry out some basic verifications that the given file is genuine. At this time, the library does not support signing artifacts.
Library usage
Fetching a bundle from GitHub's Artifact Attestations API and verifying it:
<?php use ThePhpFoundation\Attestation\AttestationException; use ThePhpFoundation\Attestation\BundleSource\DownloadGitHubBundle; use ThePhpFoundation\Attestation\FilenameWithChecksum; use ThePhpFoundation\Attestation\FulcioSigstoreOidExtensions; use ThePhpFoundation\Attestation\Verification\VerifyBundleWithOpenSsl; try { $file = FilenameWithChecksum::fromFilename($fileYouWantToVerify); $bundles = DownloadGitHubBundle::factory('your-org') // the org/user in your GH URL, e.g. https://github.com/your-org ->getBundles($file); VerifyBundleWithOpenSsl::factory( [ FulcioSigstoreOidExtensions::SOURCE_REPOSITORY_URI => 'https://github.com/your-org/your-repo', FulcioSigstoreOidExtensions::SOURCE_REPOSITORY_OWNER_URI => 'https://github.com/your-org', ], // the workflow that's expected to have produced the signing certificate 'https://github.com/your-org/your-repo/.github/workflows/build.yml@refs/heads/main', // the expected issuer of the signing certificate 'https://token.actions.githubusercontent.com', ) ->verify($bundles, $file); } catch (AttestationException $issue) { // Handle a failure to fetch or verify the attestation in the way you see fit... }
CLI usage
A verify-bundle command is provided, implementing a subset of the
Sigstore conformance CLI protocol,
to verify a local Sigstore bundle file against a local artifact:
php bin/cli.php verify-bundle \ --bundle=path/to/bundle.json \ --certificate-identity=https://github.com/your-org/your-repo/.github/workflows/build.yml@refs/heads/main \ --certificate-oidc-issuer=https://token.actions.githubusercontent.com \ path/to/artifact
Pass --trusted-root=path/to/trusted-root.jsonl to verify against a custom
trusted root instead of the one bundled with this library.