Cosign 容器签名

发布时间: 更新时间: 总字数:618 阅读时间:2m 作者:IP:上海 网址

Cosign用来为容器签名(Signing)、验证(Verification)和在 OCI Registry 存储

介绍

Cosign的目的是使签名成为无形的基础设施。

安装

  • go 安装
go install github.com/sigstore/cosign/cmd/cosign@latest
  • binary
wget "https://github.com/sigstore/cosign/releases/download/v1.6.0/cosign-linux-amd64"
mv cosign-linux-amd64 /usr/local/bin/cosign
chmod +x /usr/local/bin/cosign

Redhat/CentOS

# rpm
wget "https://github.com/sigstore/cosign/releases/download/v1.6.0/cosign-1.6.0.x86_64.rpm"
rpm -ivh cosign-1.6.0.x86_64.rpm

Ubuntu

# dkpg
wget "https://github.com/sigstore/cosign/releases/download/v1.6.0/cosign_1.6.0_amd64.deb"
dpkg -i cosign_1.6.0_amd64.deb

Mac

brew install cosign

Help

cosign-help

使用

Generate a keypair

$ cosign generate-key-pair
Enter password for private key:
Enter password for private key again:
Private key written to cosign.key
Public key written to cosign.pub

Sign a container and store the signature in the registry

$ cosign sign --key cosign.key xiexianbin/nettools:1
Enter password for private key:
Pushing signature to: index.docker.io/xiexianbin/nettools

Verify a container against a public key

$ cosign verify --key cosign.pub index.docker.io/xiexianbin/nettools:1 | jq .

Verification for index.docker.io/xiexianbin/nettools:1 --
The following checks were performed on each of these signatures:
  - The cosign claims were validated
  - The signatures were verified against the specified public key
[
  {
    "critical": {
      "identity": {
        "docker-reference": "index.docker.io/xiexianbin/nettools"
      },
      "image": {
        "docker-manifest-digest": "sha256:aac519b2ee85b092f729185c267357f97f298783ce2f698a383607fab4155cbf"
      },
      "type": "cosign container image signature"
    },
    "optional": null
  }
]

其他

  • 也可以支持其他 Artifacts 的签名 cosign sign-blob
  • cosign 支持和 KMS 以前签署和验证,如 Hashicorp Vault
  • 类似的工具
    • Sigstore 容器和二进制文件的代码签名
本文总阅读量 次 本站总访问量 次 本站总访客数