# インストール $ sudo tar -xvzf notation_$NOTATION_VERSION\_linux_amd64.tar.gz -C /usr/local/bin notation $ notation version Notation - a tool to sign and verify artifacts.
Version: 2.0.0-alpha.1 Go version: go1.24.1 Git commit: 6c5c35a0207eebf8d4d6d2efad66b798457a6622
コンテナレジストリを起動
DockerHubにプッシュしてもよいですが、単なる技術検証で用いるのは迷惑だと思ったので、ローカルPC上にレジストリを起動させます。同じく、CNCFのSandboxプロジェクトの、 Zot という軽量OCIレジストリを利用します。
$ notation cert generate-test --default "suji-toshi-mashoya" generating RSA Key with 2048 bits generated certificate expiring on 2025-06-14T10:57:29Z wrote key: /home/mano/.config/notation/localkeys/suji-toshi-mashoya.key wrote certificate: /home/mano/.config/notation/localkeys/suji-toshi-mashoya.crt Successfully added suji-toshi-mashoya.crt to named store suji-toshi-mashoya of type ca suji-toshi-mashoya: added to the key list suji-toshi-mashoya: mark as default signing ke
notation key ls や notation cert ls で署名キーや証明書を確認できます。
イメージに署名
適当なイメージをpullし、ローカル上のZotレジストリにpushします。
$ docker pull busybox:1.37.0 $ docker tag busybox:1.37.0 localhost:5000/suji-tootteruyo:1.0 $ docker push localhost:5000/suji-tootteruyo:1.0 The push refers to repository [localhost:5000/suji-tootteruyo] 90b9666d4aed: Pushed 1.0: digest: sha256:7c0ffe5751238c8479f952f3fbc3b719d47bccac0e9bf0a21c77a27cba9ef12d size: 610
i Info → Not all multiplatform-content is present and only the available single-platform image was pushed sha256:f85340bf132ae937d2c2a763b8335c9bab35d6e8293f70f606b9c6178d84f42b -> sha256:7c0ffe5751238c8479f952f3fbc3b719d47bccac0e9bf0a21c77a27cba9ef12d
$ notation sign --insecure-registry "localhost:5000/suji-tootteruyo@sha256:7c0ffe5751238c8479f952f3fbc3b719d47bccac0e9bf0a21c77a27cba9ef12d" Successfully signed localhost:5000/suji-tootteruyo@sha256:7c0ffe5751238c8479f952f3fbc3b719d47bccac0e9bf0a21c77a27cba9ef12d Pushed the signature to localhost:5000/suji-tootteruyo@sha256:ef3915777084e9f5fb59fa2b2184d60f452bd374352e2afdb1c20aac637c3304```
以下で紐づきを確認できます。
$ notation ls localhost:5000/suji-tootteruyo@sha256:7c0ffe5751238c8479f952f3fbc3b719d47bccac0e9bf0a21c77a27cba9ef12d localhost:5000/suji-tootteruyo@sha256:7c0ffe5751238c8479f952f3fbc3b719d47bccac0e9bf0a21c77a27cba9ef12d └── application/vnd.cncf.notary.signature └── sha256:f42031db9c3000605abfefa753db67e7928c7a907bbf5160c994d4944919958a
$ notation cert generate-test --default "fade-out" $ notation key ls NAME KEY PATH CERTIFICATE PATH ID PLUGIN NAME suji-toshi-mashoya /home/mano/.config/notation/localkeys/suji-toshi-mashoya.key /home/mano/.config/notation/localkeys/suji-toshi-mashoya.crt * fade-out /home/mano/.config/notation/localkeys/fade-out.key /home/mano/.config/notation/localkeys/fade-out.crt
前回のキーと、今回の攻撃用のキーの2種類存在します。 fade-out が攻撃用のキーです。
新しく別のイメージを準備します。前回利用した1.37.0 ではなく、1.36.0を利用します。
$ docker pull busybox:1.36.0 $ docker tag busybox:1.36.0 localhost:5000/suji-tooranaiyo:1.0 $ docker push localhost:5000/suji-tooranaiyo:1.0 The push refers to repository [localhost:5000/suji-tooranaiyo] a58ecd4f0c86: Pushed 1.0: digest: sha256:086417a48026173aaadca4ce43a1e4b385e8e62cc738ba79fc6637049674cac0 size: 528
i Info → Not all multiplatform-content is present and only the available single-platform image was pushed sha256:9e2bbca079387d7965c3a9cee6d0c53f4f4e63ff7637877a83c4c05f2a666112 -> sha256:086417a48026173aaadca4ce43a1e4b385e8e62cc738ba79fc6637049674cac0
このイメージに対して、攻撃用のキーで署名します。
$ notation sign \ --insecure-registry \ --key fade-out \ "localhost:5000/suji-tooranaiyo@sha256:086417a48026173aaadca4ce43a1e4b385e8e62cc738ba79fc6637049674cac0" Successfully signed localhost:5000/suji-tooranaiyo@sha256:086417a48026173aaadca4ce43a1e4b385e8e62cc738ba79fc6637049674cac0 Pushed the signature to localhost:5000/suji-tooranaiyo@sha256:49fc8cc2e956660bb8c6ab9cd18618609eb106ae5503855e7b2b3de5138c7ec6
これで、信頼できない署名付きのイメージが作成されましたので、このイメージを検証します。
$ notation verify --insecure-registry localhost:5000/suji-tooranaiyo@sha256:49fc8cc2e956660bb8c6ab9cd18618609eb106ae5503855e7b2b3de5138c7ec6 Error: signature verification failed: artifact "localhost:5000/suji-tooranaiyo@sha256:49fc8cc2e956660bb8c6ab9cd18618609eb106ae5503855e7b2b3de5138c7ec6" has no applicable oci trust policy statement. Trust policy applicability for a given artifact is determined by registryScopes. To create a trust policy, see: https://notaryproject.dev/docs/quickstart/#create-a-trust-policy