本文へスキップ
ecdsa.com
Sigstore cosign 2.x/3.xその他のツール

エラーメッセージ

--certificate-identity or --certificate-identity-regexp is required for verification in keyless mode

別の表記

  • Error: --certificate-identity or --certificate-identity-regexp is required for verification in keyless mode

cosign では `--certificate-oidc-issuer`(または `--certificate-oidc-issuer-regexp`)も必須ですが、ID のフラグが先に確認されます。cosign 1.x では、これらのフラグを指定しなくてもキーレス検証が通りました。

Sigstore cosign 2.x/3.x — verify / verify-blob / verify-attestation without --key

このエラーの意味

`--key` を指定しない場合、cosign は「キーレス」署名を検証します。Fulcio が発行する有効期間の短い証明書によって、署名は OIDC の ID(CI ワークフローやメールアドレス)に結び付けられます。有効なキーレス署名が証明するのは、*何らかの* ID を持つ*誰か*が署名したということだけです。そのため cosign 2.0 以降では、誰の署名を受け入れるのかを指定する必要があります。期待する ID と発行者を指定しない限り、コマンドはバンドルを読み込む前に停止します。

発生する理由

修正方法

  1. 1.

    ワークフローの ID と発行者を固定する

    GitHub Actions の場合、発行者は `https://token.actions.githubusercontent.com`、ID は特定の ref におけるワークフローファイルです。

    bash
    # Artifacts signed in GitHub Actions: identity = workflow file at a ref, issuer = GitHub's OIDC issuer
    cosign verify-blob \
      --bundle app.sigstore.json \
      --certificate-identity "https://github.com/acme/app/.github/workflows/release.yml@refs/tags/v1.4.2" \
      --certificate-oidc-issuer "https://token.actions.githubusercontent.com" \
      app.tar.gz
  2. 2.

    範囲を許可するにはアンカー付きの正規表現を使う

    `--certificate-identity-regexp` を使うと、1 つのワークフローのすべてのタグを受け入れられます。正規表現には必ずアンカーを付けてください。付けないと、フォークのワークフローも一致するおそれがあります。

    bash
    # Any release tag of that workflow - anchor the expression
    cosign verify ghcr.io/acme/app:1.4.2 \
      --certificate-identity-regexp '^https://github\.com/acme/app/\.github/workflows/release\.yml@refs/tags/v[0-9]+\.[0-9]+\.[0-9]+$' \
      --certificate-oidc-issuer https://token.actions.githubusercontent.com
  3. 3.

    証明書から ID を読み取る

    バンドルに含まれる証明書のサブジェクト代替名が、固定すべき値です。ただし、固定するのは、その ID が信頼する相手のものだと判断してからにしてください。

    bash
    # Read the identity recorded in the signing certificate of a bundle
    jq -r '.verificationMaterial.certificate.rawBytes' app.sigstore.json | base64 -d \
      | openssl x509 -inform DER -noout -ext subjectAltName

関連するエラー

署名エラーデータベースをすべて見る