1. Go to this page and download the library: Download k2gl/sigstore-sign library. Choose the download type require.
2. Extract the ZIP file and open the index.php.
3. Add this code to the index.php.
<?php
require_once('vendor/autoload.php');
/* Start to develop here. Best regards https://php-download.com/ */
k2gl / sigstore-sign example snippets
use K2gl\Dsse\EcdsaP256Signer;
use K2gl\RekorClient\{RekorClient, KeyDetails};
use K2gl\SigstoreSign\{SigstoreSigner, SigningKey, TsaClient};
$rekor = new RekorClient($psr18, $psr17, $psr17, 'https://rekor.sigstore.dev');
$tsa = new TsaClient($psr18, $psr17, $psr17, 'https://timestamp.sigstore.dev');
$signer = new SigstoreSigner($rekor, $tsa);
// The key: a DSSE signer for the private half, plus the public half — here a
// public-key hint (or use SigningKey::certificate() with a Fulcio leaf).
$key = SigningKey::publicKey(
signer: EcdsaP256Signer::fromPem(file_get_contents('signing-key.pem'), null),
publicKeyDer: $publicKeyDer,
keyDetails: KeyDetails::PKIX_ECDSA_P256_SHA_256,
hint: $hexSha256OfThePublicKey,
);
// Sign an artifact → a message-signature bundle.
$bundleJson = $signer->signArtifact(file_get_contents('release.tar.gz'), $key)->toJson();
// …or sign an attestation payload (e.g. an in-toto Statement) → a DSSE bundle.
$bundleJson = $signer->signAttestation($statementJson, 'application/vnd.in-toto+json', $key)->toJson();
use K2gl\SigstoreSign\{AmbientCredentials, FulcioClient, FulcioSigningKey, SigstoreSigner};
// The CI identity token (GitHub Actions needs `id-token: write`).
$oidcToken = AmbientCredentials::githubActions($psr18, $psr17);
// …or AmbientCredentials::gitlabCi() for a GitLab id_token.
$fulcio = new FulcioClient($psr18, $psr17, $psr17, 'https://fulcio.sigstore.dev');
$key = FulcioSigningKey::create($fulcio, $oidcToken); // ephemeral key + Fulcio certificate
$bundleJson = (new SigstoreSigner($rekor, $tsa))->signArtifact($artifact, $key)->toJson();
use K2gl\RekorClient\RekorApiVersion;
use K2gl\RekorClient\RekorClient;
use K2gl\SigstoreSign\SigningConfig;
// fetched through k2gl/tuf, next to the trusted root
$target = $updater->getTargetInfo('signing_config.v0.2.json');
$config = SigningConfig::fromJson($updater->downloadTarget($target));
$log = $config->rekorLog();
$rekor = new RekorClient(
$psr18, $psr17, $psr17,
baseUrl: $log->url,
apiVersion: RekorApiVersion::from($log->majorApiVersion),
);
$fulcio = new FulcioClient($psr18, $psr17, $psr17, $config->certificateAuthority()->url);
$tsa = new TsaClient($psr18, $psr17, $psr17, $config->timestampAuthorities()[0]->url);
Loading please wait ...
Before you can download the PHP files, the dependencies should be resolved. This can take some minutes. Please be patient.