Skip to content

Commit a9f95b4

Browse files
committed
update per junjie's comment
Signed-off-by: Yi Zha <[email protected]>
1 parent 503b260 commit a9f95b4

File tree

1 file changed

+17
-13
lines changed

1 file changed

+17
-13
lines changed

articles/container-registry/container-registry-tutorial-sign-build-push.md

Lines changed: 17 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,7 @@ In this tutorial:
4040
curl -Lo notation.tar.gz https://github.com/notaryproject/notation/releases/download/v1.0.0/notation_1.0.0_linux_amd64.tar.gz
4141
tar xvzf notation.tar.gz
4242

43-
# Copy the Notation binary to the desired bin directory in your $PATH
43+
# Copy the Notation binary to the desired bin directory in your $PATH, for example
4444
cp ./notation /usr/local/bin
4545
```
4646

@@ -75,9 +75,9 @@ In this tutorial:
7575
1. Configure AKV resource names.
7676

7777
```bash
78-
# Name of the existing Azure Key Vault used to store the signing keys
78+
# Name of the existing AKV used to store the signing keys
7979
AKV_NAME=myakv
80-
# New desired key name used to sign and verify
80+
# Name of the certificate created in AKV
8181
CERT_NAME=wabbit-networks-io
8282
CERT_SUBJECT="CN=wabbit-networks.io,O=Notation,L=Seattle,ST=WA,C=US"
8383
CERT_PATH=./${CERT_NAME}.pem
@@ -100,7 +100,7 @@ In this tutorial:
100100

101101
## Sign in with Azure CLI
102102

103-
```azure-cli
103+
```bash
104104
az login
105105
```
106106

@@ -111,16 +111,21 @@ To learn more about Azure CLI and how to sign in with it, see [Sign in with Azur
111111
To create a self-signed certificate and sign a container image in AKV, you must assign proper access policy to a principal. The permissions that you grant for a principal should include at least certificate permissions `Create` and `Get` for creating and get certificates, and key permissions `Sign` for signing. A principal can be user principal, service principal or managed identity. In this tutorial, the access policy is assigned to a signed-in Azure user. To learn more about assigning policy to a principal, see [Assign Access Policy](/azure/key-vault/general/assign-access-policy).
112112

113113
### Set the subscription that contains the AKV resource
114-
```azure-cli
114+
115+
```bash
115116
az account set --subscription <your_subscription_id>
116117
```
117118

118119
### Set the access policy in AKV
119-
```azure-cli
120+
121+
```bash
120122
USER_ID=$(az ad signed-in-user show --query id -o tsv)
121123
az keyvault set-policy -n $AKV_NAME --certificate-permissions create get --key-permissions sign --object-id $USER_ID
122124
```
123125

126+
> [!NOTE]
127+
> The permissions granted are necessary for creating a certificate and signing a container image. Depending on your requirements, you may need to grant additional permissions.
128+
124129
## Create a self-signed signing certificate in AKV (Azure CLI)
125130

126131
The following steps show how to create a self-signed signing certificate for testing purpose.
@@ -158,24 +163,24 @@ The following steps show how to create a self-signed signing certificate for tes
158163
159164
2. Create the certificate.
160165
161-
```azure-cli
166+
```bash
162167
az keyvault certificate create -n $CERT_NAME --vault-name $AKV_NAME -p @my_policy.json
163168
```
164169
165170
## Sign a container image with Notation CLI and AKV plugin
166171
167172
1. Build and push a new image with ACR Tasks. Always use digest to identify the image for signing, because tags are mutable and and can be overwritten.
168173
169-
```azure-cli
174+
```bash
170175
DIGEST=$(az acr build -r $ACR_NAME -t $REGISTRY/${REPO}:$TAG $IMAGE_SOURCE --no-logs --query "outputImages[0].digest" -o tsv)
171176
IMAGE=$REGISTRY/${REPO}@$DIGEST
172177
```
173178
174179
2. Authenticate with your individual Azure AD identity to use an ACR token.
175180
176-
```azure-cli
177-
export USER_NAME="00000000-0000-0000-0000-000000000000"
178-
export PASSWORD=$(az acr login --name $ACR_NAME --expose-token --output tsv --query accessToken)
181+
```bash
182+
USER_NAME="00000000-0000-0000-0000-000000000000"
183+
PASSWORD=$(az acr login --name $ACR_NAME --expose-token --output tsv --query accessToken)
179184
notation login -u $USER_NAME -p $PASSWORD $REGISTRY
180185
```
181186
@@ -207,8 +212,7 @@ To verify the container image, you need to add the root certificate that signs t
207212
1. Download public certificate.
208213
209214
```bash
210-
CERT_ID=$(az keyvault certificate show -n $KEY_NAME --vault-name $AKV_NAME --query 'id' -o tsv)
211-
az keyvault certificate download --file $CERT_PATH --id $CERT_ID --encoding PEM
215+
az keyvault certificate download --name $CERT_NAME --vault-name $AKV_NAME --file $CERT_PATH
212216
```
213217
214218
2. Add the downloaded public certificate to named trust store for signature verification.

0 commit comments

Comments
 (0)