Skip to main content

Sign container images using cosign KMS plugin

Before signing an image, ensure that it has already been pushed to the container registry. Cosign resolves the image tag to its immutable digest and signs the digest rather than the tag.

Wichtig

The Cosign KMS plugin feature is supported with Cosign version 3.x and later.

cosign sign --key "digicert://alias/my-cosign-key" registry.example.com/myapp@sha256:<DIGEST>
  • By default, cosign also uploads the signature to the public Rekor transparency log.

cosign sign-blob \
  --key "digicert://alias/my-cosign-key" \
  --bundle artifact.sigstore.json \
  artifact.bin

The --bundle file contains both the signature and associated verification material. Distribute it alongside the artifact and provide it to verify-blob during verification.

cosign attest \
  --key "digicert://alias/my-cosign-key" \
  --predicate sbom.spdx.json \
  --type spdxjson \
  registry.example.com/myapp@sha256:<DIGEST>

Many enterprise users sign artifacts with a private, Software Trust Manager-managed key and prefer not to have the signing event recorded in the public Rekor transparency log. Use the following methods to skip transparency logging:

Where no_tlog.json contains:

{
  "mediaType": "application/vnd.dev.sigstore.signingconfig.v0.2+json",
  "rekorTlogUrls": [],
  "tsaUrls": []
}
# Container images
cosign verify --key "digicert://alias/my-cosign-key" registry.example.com/myapp@sha256:<DIGEST>

# Blobs
cosign verify-blob \
  --key "digicert://alias/my-cosign-key" \
  --bundle artifact.sigstore.json \
  artifact.bin

# Attestations
cosign verify-attestation --key "digicert://alias/my-cosign-key" registry.example.com/myapp@sha256:<DIGEST>

If the signature was created with an empty rekorTlogUrls signing config), include the --insecure-ignore-tlog option when verifying the signature because no transparency log entry is available for verification.

Verification methods: Local vs. Server-side

The plugin supports two verification modes, controlled by SM_VERIFY_SERVER_SIDE:

Mode

How to enable

Behavior

Local (default)

(no action needed)

The plugin retrieves the keypair's public key or certificate once and performs signature verification locally using Go's standard cryptographic libraries. This approach minimizes network calls and provides fast, efficient verification.

Server-side

SM_VERIFY_SERVER_SIDE=true

The plugin sends the digest and signature to the Software Trust Manager Verify API, which verifies the signature and validates the certificate's revocation status and the signing key's status. This approach requires network access during verification but provides stronger compliance and audit assurance.

Error

Description

Solution

error: unable to find "sigstore-kms-digicert" plugin (or similar exec/lookup error)

Plugin not found by cosign

  1. Confirm the binary is on PATH: which sigstore-kms-digicert (Linux/macOS) or Get-Command sigstore-kms-digicert (Windows).

  2. The binary name must be exactly sigstore-kms-digicert (or sigstore-kms-digicert.exe on Windows). Cosign derives the expected binary name from the digicert scheme in your --key/--kms URI.

  3. On Linux/macOS, confirm the binary is executable: chmod +x sigstore-kms-digicert.

failed to setup STM client or 401 Unauthorized

Authentication failures

  1. Confirm all four required env vars (SM_HOST, SM_API_KEY, SM_CLIENT_CERT_FILE, SM_CLIENT_CERT_PASSWORD) are exported in the same shell/CI job that runs cosign.

  2. Verify the certificate password: openssl pkcs12 -info -in $SM_CLIENT_CERT_FILE -passin env:SM_CLIENT_CERT_PASSWORD.

  3. The API key must have signing and certificate retrieval permissions in the STM portal.

keypair not found: <alias-or-id>

Keypair not found

  1. Run smctl keypair list to see available aliases.

  2. Aliases are case-sensitive.

  3. The Software Trust Manager API key must have access to the keypair, verify project membership in the portal.

keypair already present for given alias <alias>. Please provide new alias

keypair_duplicate error when generating a key

cosign generate-key-pair was run with an alias that already exists in Software Trust Manager. Choose a new, unused alias.

verify/verify-blob fails with something like no valid signatures found or an empty -rekorTlogUrls signing config.

Signature verification fails after signing without a transparency log

Add --insecure-ignore-tlog to the verify command, since there is intentionally no transparency log entry to check.

Enable KMS cosign debugging for detailed logs and troubleshooting.

export SM_LOG_LEVEL=debug
export SM_LOG_OUTPUT=stdout
cosign sign --key "digicert://alias/my-cosign-key" --yes <IMAGE DIGEST>

Logs are also written to $SM_HOME/logs/ by default.