Skip to content

Commit d44142f

Browse files
committed
release v0.1.2
1 parent e9d54a9 commit d44142f

File tree

9 files changed

+291
-61
lines changed

9 files changed

+291
-61
lines changed

.gitignore

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,10 +15,12 @@
1515
*.out
1616

1717
# Dependency directories (remove the comment below to include it)
18-
vendor/
18+
# vendor/
1919

2020
# Go workspace file
2121
go.work
2222

2323
# Ide file
2424
.idea/
25+
26+
dist/

.goreleaser.yml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -22,8 +22,8 @@ builds:
2222
binary: notation-alibabacloud.secretmanager.plugin
2323
ldflags:
2424
- -extldflags "-static"
25-
- -X github.com/AliyunContainerService/notation-alibabacloud-secret-manager/pkg/version.Version={{.Version}}
26-
- -X github.com/AliyunContainerService/notation-alibabacloud-secret-manager/pkg/version.GitCommit={{.Commit}}
25+
- -X github.com/AliyunContainerService/notation-alibabacloud-secret-manager/internal/version.Version={{.Version}}
26+
- -X github.com/AliyunContainerService/notation-alibabacloud-secret-manager/internal/version.CommitID={{.Commit}}
2727
archives:
2828
- format: tar.gz
2929
# this name template makes the OS and Arch compatible with the results of `uname`.

Makefile

Lines changed: 8 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -2,15 +2,14 @@ MODULE = github.com/AliyunContainerService/notation-alibabacloud-secret-
22
PLUGIN = notation-alibabacloud-secret-manager
33
GIT_TAG = $(shell git describe --tags --abbrev=0 --exact-match 2>/dev/null)
44
BUILD_METADATA =
5-
ifeq ($(GIT_TAG),) # unreleased build
6-
GIT_COMMIT = $(shell git rev-parse HEAD)
7-
GIT_STATUS = $(shell test -n "`git status --porcelain`" && echo "dirty" || echo "unreleased")
8-
BUILD_METADATA = $(GIT_COMMIT).$(GIT_STATUS)
9-
endif
10-
LDFLAGS=-buildid= -X github.com/AliyunContainerService/notation-alibabacloud-secret-manager/internal/version.Version=$(GIT_TAG) \
11-
-X github.com/AliyunContainerService/notation-alibabacloud-secret-manager/internal/version.GitCommit=$(GIT_COMMIT)
12-
13-
GO_BUILD_FLAGS = --ldflags="$(LDFLAGS)"
5+
COMMIT ?= $(shell git rev-parse HEAD)
6+
COMMIT_SHORT ?= $(shell git rev-parse --short HEAD)
7+
PACKAGE = github.com/AliyunContainerService/notation-alibabacloud-secret-manager
8+
GO_LDFLAGS := -extldflags "-static"
9+
# GO_LDFLAGS += -w -s # Drop debugging symbols.
10+
GO_LDFLAGS += -X $(PACKAGE)/internal.Version=$(GIT_TAG) \
11+
-X $(PACKAGE)/internal.CommitID=$(COMMIT_SHORT)
12+
GO_BUILD_FLAGS := -ldflags '$(GO_LDFLAGS)'
1413

1514
PLATFORMS=darwin linux windows
1615
ARCHITECTURES=amd64

README-zh_CN.md

Lines changed: 166 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,166 @@
1+
# Alibaba Cloud Secret Manager plugin for Notation
2+
3+
本仓库包含 [Notation](https://notaryproject.dev/)[阿里云KMS凭据管家](https://www.alibabacloud.com/help/en/kms/support/overview-6) 签名插件的实现。用户可以使用阿里云凭据管家中的私钥和证书,基于Notation社区的插件规范对指定镜像签名。
4+
5+
> **注意** Notary的项目文档可参考[这里](https://notaryproject.dev/docs/). 你也可以在Notary项目的 [README](https://github.com/notaryproject/.github/blob/main/README.md) 文件中了解更多关于Notary项目的信息。
6+
7+
8+
9+
## 快速开始
10+
11+
本文档介绍了如何使用 Alibaba Cloud Secret Manager Notation 插件对 OCI 构件进行签名和验证。
12+
13+
14+
#### 插件规范兼容性
15+
16+
| Capability | Compatibility |
17+
| ---------------- | ------------------------------------------------------------ |
18+
| keySpec | `RSA-2048`, `RSA-3072`, `EC-256` |
19+
| hashAlgorithm | `SHA-256` |
20+
| signingAlgorithm | `RSASSA-PSS-SHA-256` |
21+
| pluginCapability | `SIGNATURE_GENERATOR.RAW`, `SIGNATURE_VERIFIER.TRUSTED_IDENTITY`, `SIGNATURE_VERIFIER.REVOCATION_CHECK` |
22+
| signingScheme | `notary.x509` |
23+
24+
25+
26+
## 入门:
27+
28+
29+
30+
下面总结了配置 notation-alibabacloud-secret-manager 插件以及容器镜像签名和验签的步骤。
31+
32+
- 安装Notation [CLI](https://github.com/notaryproject/notation/releases/tag/v1.1.1)。版本 v1.1.1 已通过测试。请注意,“make install ”会根据 MacOS 环境创建插件目录结构。请根据您的操作系统更新 Makefile。然后,它会根据符号插件目录结构规范将插件复制到适当的位置。
33+
34+
- 本插件使用 [KMS Instance SDK](https://www.alibabacloud.com/help/en/kms/developer-reference/kms-instance-sdk-for-go/),您需要满足以下先决条件并自定义环境变量:
35+
36+
37+
38+
| 环境变量 | 描述 |
39+
| ------------------------------------ | ------------------------------------------------------------ |
40+
| ALIBABA_CLOUD_ACCESS_KEY_ID | 阿里云账户Access Key ID |
41+
| ALIBABA_CLOUD_ACCESS_KEY_SECRET | 阿里云账号Access Secret Key |
42+
| ALIBABA_CLOUD_KMS_INSTANCE_ENDPOINT | 指定KMS专属实例的VPC Endpoint,比如:kst-hzxxxxxxxxxx.cryptoservice.kms.aliyuncs.com |
43+
| ALIBABA_CLOUD_KMS_CLIENTKEY_FILEPATH | 访问指定KMS专属实例应用接入点(AAP)的ClientKey凭据文件对应的本地文件路径 |
44+
| ALIBABA_CLOUD_KMS_PASSWORD | 指定KMS专属实例应用接入点(AAP)的密钥 |
45+
| ALIBABA_CLOUD_KMS_CA_FILEPATH | 指定KMS专属实例CA证书对应的本地文件路径 |
46+
47+
*注意:notation-alibabacloud-secret-manager插件支持多种Credential配置方式。更多的配置方式请参考[credentials](https://aliyuncontainerservice.github.io/ack-ram-tool/#credentials)*
48+
49+
50+
51+
## 安装
52+
53+
54+
55+
您可以通过 [Releases](https://github.com/AliyunContainerService/notation-alibabacloud-secret-manager/releases) 页面下载最新版的命令行工具,或选择基于源码构建和安装
56+
57+
```bash
58+
git clone
59+
cd notation-alibabacloud-secret-manager
60+
make build
61+
```
62+
63+
64+
65+
在下载或构建完成对应的plugin二进制文件后,可以在目标环境上通过执行如下的notation CLI指令完成安装:
66+
67+
```bash
68+
notation plugin add --file ./notation-alibabacloud.secretmanager.plugin
69+
```
70+
71+
*--file参数指向plugin二进制文件所在路径*
72+
73+
74+
75+
### 管理KMS实例
76+
77+
用户可以在控制台启用并管理KMS实例,请关注[启用KMS实例](https://www.alibabacloud.com/help/zh/kms/key-management-service/user-guide/manage-kms-instances)的前提条件
78+
79+
插件支持使用KMS实例创建并管理的或使用自签并导入KMS实例这两种类型的密钥进行签名:
80+
81+
### 方式1:使用KMS创建并管理密钥
82+
83+
用户可以在KMS服务控制台通过以下步骤[创建密钥](https://help.aliyun.com/zh/kms/key-management-service/user-guide/manage-keys-2):
84+
85+
1. 登录密钥管理服务控制台,在顶部菜单栏选择地域后,在左侧导航栏单击资源 > 密钥管理。
86+
87+
2. 在密钥管理页面,单击用户主密钥页签,实例ID选择软件密钥管理实例,单击创建密钥。
88+
89+
3. 在创建密钥面板,完成配置项设置,注意这里的密钥规格需要选择**非对称密钥**,密钥用途选择**SIGN/VERIFY**,密钥规则选择上文插件规范兼容性里支持的密钥规格(`RSA-2048`, `RSA-3072`, `EC-256`),然后单击确定。
90+
91+
92+
93+
### 方式2: 使用自签并导入的密钥物料
94+
95+
用户可以使用自签密钥并将密钥材料导入KMS实例管理。作为快速入门,本教程使用 openssl 生成私钥和证书
96+
97+
1. 在 KMS 控制台创建非对称密钥,请参考[步骤1](https://www.alibabacloud.com/help/zh/kms/key-management-service/user-guide/import-key-material-into-an-asymmetric-key#p-qcf-3d4-pel)
98+
99+
2. 下载包装公钥和导入令牌,请参考[步骤2](https://www.alibabacloud.com/help/zh/kms/key-management-service/user-guide/import-key-material-into-an-asymmetric-key#p-f9p-n7u-88m)
100+
101+
3. 使用包装公钥加密密钥材料,请参考[步骤3](https://www.alibabacloud.com/help/zh/kms/key-management-service/user-guide/import-key-material-into-an-asymmetric-key#p-jar-kxa-iun)
102+
103+
4. 导入密钥材料,请参见[步骤4](https://www.alibabacloud.com/help/zh/kms/key-management-service/user-guide/import-key-material-into-an-asymmetric-key#p-j5c-vp9-9vd)
104+
105+
![](./docs/import_key.png)
106+
107+
*用户可以使用如下命令基于步骤3中的私钥 TakPrivPkcs1.pem 和[openssl.cnf](./docs/sample_openssl.cnf) 中的 server_cert 配置获取用于验签的x509 证书,也可以使用插件在签名时自动导出证书*
108+
109+
```bash
110+
openssl req -x509 -new -nodes -key TakPrivPkcs1.pem -sha256 -days 3650 -out sign.crt -config openssl.cnf -extensions server_cert
111+
```
112+
113+
114+
115+
## 使用Notation进行制品签名
116+
117+
到此我们已经完成了所有配置,让我们使用Notation CLI开始制品签名。如果您还没有下载过notation CLI工具,可以从[这里](https://github.com/notaryproject/notation/releases)获取。
118+
119+
```bash
120+
notation sign --id <keyId> --plugin alibabacloud.secretmanager.plugin <myRegistry>/<myRepo>@<digest> --plugin-config output_cert_dir=<dirPath>
121+
```
122+
123+
124+
125+
| 参数 | 说明 |
126+
| ------------- | ------------------------------------------------------------ |
127+
| id | 指定的阿里云KMS实例ID |
128+
| plugin-config | 插件自定义参数,支持如下配置:<br /> output_cert_dir:签名过程中可以使用该参数基于指定的KMS密钥签发对应的x509验签证书,并以文件形式输出到参数指定文件目录下<br /> ca_certs:使用自签并导入KMS实例的密钥加签时,如果您同时使用密钥签发了X509证书,可以使用该参数指定自签证书对应的文件路径 |
129+
130+
131+
132+
133+
## 使用Notation完成制品验签
134+
1. 配置trust store:
135+
136+
```bash
137+
./notation cert add -t ca -s ack.notation "{path-to-cert}/signer.crt"
138+
```
139+
其中`signer.crt`是之前签名时插件输出的证书或用户指定的自签证书
140+
2. 配置trust policy:
141+
```bash
142+
cat <<EOF > ./trustpolicy.json
143+
{
144+
"version": "1.0",
145+
"trustPolicies": [
146+
{
147+
"name": "acr-hangzhou-images",
148+
"registryScopes": [ "<myRegistry>/<myRepo>" ],
149+
"signatureVerification": {
150+
"level" : "strict"
151+
},
152+
"trustStores": [ "ca:ack.notation" ],
153+
"trustedIdentities": [
154+
"*"
155+
]
156+
}
157+
]
158+
}
159+
EOF
160+
```
161+
```bash
162+
./notation policy import ./trustpolicy.json
163+
```
164+
3. 制品验签:
165+
```bash
166+
./notation verify <myRegistry>/<myRepo>@<digest> -v

0 commit comments

Comments
 (0)