You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: articles/container-registry/container-registry-tutorial-sign-build-push.md
+30-59Lines changed: 30 additions & 59 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -1,19 +1,19 @@
1
1
---
2
2
title: Build, Sign and Verify a container image using notation and certificate in Azure Key Vault
3
3
description: In this tutorial you'll learn to create a signing certificate, build a container image, remote sign image with notation and Azure Key Vault, and then verify the container image using the Azure Container Registry.
4
-
author: dtzar
4
+
author: feynmanzhou
5
5
ms.author: davete
6
6
ms.service: container-registry
7
7
ms.custom: devx-track-azurecli
8
8
ms.topic: how-to
9
-
ms.date: 12/12/2022
9
+
ms.date: 4/23/2023
10
10
---
11
11
12
12
# Build, sign, and verify container images using Notary and Azure Key Vault (Preview)
13
13
14
-
The Azure Key Vault (AKV) is used to store a signing key that can be utilized by **notation** with the notation AKV plugin (azure-kv) to sign and verify container images and other artifacts. The Azure Container Registry (ACR) allows you to attach these signatures using the **az** or **oras** CLI commands.
14
+
The Azure Key Vault (AKV) is used to store a signing key that can be utilized by [notation](http://notaryproject.dev/) with the notation AKV plugin (azure-kv) to sign and verify container images and other artifacts. The Azure Container Registry (ACR) allows you to attach these signatures using the **az** or **oras** CLI commands.
15
15
16
-
The signed containers enable users to assure deployments are built from a trusted entity and verify artifact hasn't been tampered with since their creation. The signed artifact ensures integrity and authenticity before the user pulls an artifact into any environment and avoid attacks.
16
+
The signed image enables users to assure deployments are built from a trusted entity and verify artifact hasn't been tampered with since their creation. The signed artifact ensures integrity and authenticity before the user pulls an artifact into any environment and avoid attacks.
17
17
18
18
19
19
In this tutorial:
@@ -31,11 +31,11 @@ In this tutorial:
31
31
32
32
## Install the notation CLI and AKV plugin
33
33
34
-
1. Install notation v1.0.0-rc.1 with plugin support on a Linux environment. You can also download the package for other environments from the [release page](https://github.com/notaryproject/notation/releases/tag/v1.0.0-rc.1).
34
+
1. Install notation v1.0.0-rc.4 on a Linux environment. You can also download the package for other environments by following the [Notation installation guide](https://notaryproject.dev/docs/installation/cli/).
# Copy the notation cli to the desired bin directory in your PATH
@@ -45,22 +45,21 @@ In this tutorial:
45
45
2. Install the notation Azure Key Vault plugin for remote signing and verification.
46
46
47
47
> [!NOTE]
48
-
> The plugin directory varies depending upon the operating system being used. The directory path below assumes Ubuntu.
49
-
> Please read the [notation config article](https://github.com/notaryproject/notaryproject.dev/blob/main/content/en/docs/how-to/directory-structure.md) for more information.
48
+
> The plugin directory varies depending upon the operating system being used. The directory path below assumes Ubuntu. Please read the [Notation directory structure for system configuration](https://notaryproject.dev/docs/concepts/directory-structure/) for more information.
tar xvzf notation-azure-kv.tar.gz -C ~/.config/notation/plugins/azure-kv notation-azure-kv
61
60
```
62
61
63
-
3. List the available plugins and verify that the plugin is available.
62
+
3. List the available plugins.
64
63
65
64
```bash
66
65
notation plugin ls
@@ -99,14 +98,14 @@ In this tutorial:
99
98
100
99
## Store the signing certificate in AKV
101
100
102
-
If you have an existing certificate, upload it to AKV. For more information on how to use your own signing key, see the [signing certificate requirements.](https://github.com/notaryproject/notaryproject/blob/v1.0.0-rc.1/specs/signature-specification.md)
101
+
If you have an existing certificate, upload it to AKV. For more information on how to use your own signing key, see the [signing certificate requirements.](https://github.com/Azure/notation-azure-kv/blob/release-0.6/docs/ca-signed-workflow.md)
103
102
Otherwise create an x509 self-signed certificate storing it in AKV for remote signing using the steps below.
104
103
105
104
### Create a self-signed certificate (Azure CLI)
106
105
107
106
1. Create a certificate policy file.
108
107
109
-
Once the certificate policy file is executed as below, it creates a valid signing certificate compatible with **notation**in AKV. The EKU listed is for code-signing, but isn't required for notation to sign artifacts. The subject is used later as trust identity that user tursts during verification.
108
+
Once the certificate policy file is executed as below, it creates a valid signing certificate compatible with **notation**in AKV. The EKU listed is for code-signing, but isn't required for notation to sign artifacts. The subject is used later as trust identity that user trust during verification.
110
109
111
110
```bash
112
111
cat <<EOF > ./my_policy.json
@@ -148,7 +147,7 @@ Otherwise create an x509 self-signed certificate storing it in AKV for remote si
148
147
az keyvault certificate download --file $CERT_PATH --id $CERT_ID --encoding PEM
> Currently, `notation` relies on [Docker Credential Store](https://docs.docker.com/engine/reference/commandline/login/#credentials-store) for authentication. Notation requires additional configuration on Linux. If `notation login` is failing, you can configure the Docker Credential Store or Notation environment variables by following the guide [Authenticate with OCI-compliant registries](https://notaryproject.dev/docs/how-to/registry-authentication/).
194
+
193
195
3. Sign the container image with the [COSE](https://datatracker.ietf.org/doc/html/rfc8152) signature format using the signing key added in previous step.
194
196
195
197
```bash
@@ -202,54 +204,16 @@ Otherwise create an x509 self-signed certificate storing it in AKV for remote si
202
204
notation ls $IMAGE
203
205
```
204
206
205
-
## View the graph of artifacts with the ORAS CLI (optional)
206
-
207
-
ACR support for OCI artifacts enables a linked graph of supply chain artifacts that can be viewed through the ORAS CLI or the Azure CLI.
208
-
209
-
1. Signed images can be view with the ORAS CLI.
210
-
211
-
```bash
212
-
oras login -u $USER_NAME -p $PASSWORD $REGISTRY
213
-
oras discover -o tree $IMAGE
214
-
```
215
-
216
-
## View the graph of artifacts with the Azure CLI (optional)
217
-
218
-
1. List the manifest details for the container image.
219
-
220
-
```azure-cli
221
-
az acr manifest show-metadata $IMAGE -o jsonc
222
-
```
223
-
224
-
2. Generates a result, showing the `digest` representing the notary v2 signature.
The trust policy is a JSON document named `trustpolicy.json`, which is stored under the notation configuration directory. Users who verify signed artifacts from a registry use the trust policy to specify trusted identities that sign the artifacts, and the level of signature verification to use.
248
212
249
-
Use the following command to configure trust policy for this tutorial. Upon successful execution of the command, one trust policy named `wabbit-networks-images` is created. This trust policy applies to all the artifacts stored in repositories defined in `$REGISTRY/$REPO`. The trust identity that user trusts has the x509 subject `$CERT_SUBJECT` from previous step, and stored under trust store named `$STORE_NAME` of type `$STORE_TYPE`. See [Trust store and trust policy specification](https://notaryproject.dev/docs/concepts/trust-store-trust-policy-specification/) for details.
213
+
Use the following command to configure trust policy. Upon successful execution of the command, one trust policy named `wabbit-networks-images` is created. This trust policy applies to all the artifacts stored in repositories defined in `$REGISTRY/$REPO`. The trust identity that user trusts has the x509 subject `$CERT_SUBJECT` from previous step, and stored under trust store named `$STORE_NAME` of type `$STORE_TYPE`. See [Trust store and trust policy specification](https://notaryproject.dev/docs/concepts/trust-store-trust-policy-specification/) for details.
@@ -268,14 +232,21 @@ ACR support for OCI artifacts enables a linked graph of supply chain artifacts t
268
232
}
269
233
EOF
270
234
```
235
+
236
+
3. Use `notation policy` to import the trust policy configuration from a JSON file that we created previously.
237
+
238
+
```bash
239
+
notation policy import ./trustpolicy.json
240
+
notation policy show
241
+
```
271
242
272
-
2. The notation command can also help to ensure the container image hasn't been tampered with since build time by comparing the `sha` with what is in the registry.
243
+
4. The notation command can also help to ensure the container image hasn't been tampered with since build time by comparing the `sha` with what is in the registry.
273
244
274
245
```bash
275
246
notation verify $IMAGE
276
247
```
277
-
Upon successful verification of the image using the trust policy, the sha256 digest of the verified image is returned in a successful output messages.
248
+
Upon successful verification of the image using the trust policy, the sha256 digest of the verified image is returned in a successful output message.
278
249
279
250
## Next steps
280
251
281
-
See [Enforce policy to only deploy signed container images to Azure Kubernetes Service (AKS) utilizing **ratify** and **gatekeeper**.](https://github.com/Azure/notation-azure-kv/blob/main/docs/nv2-sign-verify-aks.md)
252
+
See [Ratify on Azure: Allow only signed images to be deployed on AKS with Notation and Ratify](https://github.com/deislabs/ratify/blob/main/docs/examples/ratify-verify-azure-cmd.md).
0 commit comments