mirror of
https://github.com/yeasy/docker_practice.git
synced 2026-08-10 16:37:34 +00:00
docs: use digest-based cosign signing
This commit is contained in:
@@ -240,8 +240,9 @@ cosign generate-key-pair
|
||||
**签名镜像:**
|
||||
|
||||
```bash
|
||||
# 使用私钥签名(推送到仓库前)
|
||||
cosign sign --key cosign.key myregistry.com/myapp:v1.0.0
|
||||
# 先推送镜像,再使用不可变 digest 签名
|
||||
IMAGE_DIGEST="myregistry.com/myapp@sha256:<digest>"
|
||||
cosign sign --key cosign.key "$IMAGE_DIGEST"
|
||||
|
||||
# 系统会提示输入私钥密码
|
||||
```
|
||||
@@ -249,7 +250,7 @@ cosign sign --key cosign.key myregistry.com/myapp:v1.0.0
|
||||
|
||||
```bash
|
||||
# 使用公钥验证
|
||||
cosign verify --key cosign.pub myregistry.com/myapp:v1.0.0
|
||||
cosign verify --key cosign.pub "$IMAGE_DIGEST"
|
||||
|
||||
# 输出结果示例
|
||||
# Verification successful!
|
||||
@@ -266,10 +267,10 @@ cosign verify --key cosign.pub myregistry.com/myapp:v1.0.0
|
||||
|
||||
```bash
|
||||
# 在 GitHub Actions 等 CI 中无需存储密钥
|
||||
cosign sign --yes myregistry.com/myapp:v1.0.0
|
||||
cosign sign --yes "$IMAGE_DIGEST"
|
||||
|
||||
# 验证时自动使用 OIDC 令牌验证身份
|
||||
cosign verify myregistry.com/myapp:v1.0.0 \
|
||||
cosign verify "$IMAGE_DIGEST" \
|
||||
--certificate-identity https://github.com/myorg/myrepo/.github/workflows/build.yml@refs/heads/main \
|
||||
--certificate-oidc-issuer https://token.actions.githubusercontent.com
|
||||
```
|
||||
|
||||
Reference in New Issue
Block a user