Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

spec: update cli sign spec for tag to digest translation #439

Merged
merged 29 commits into from
Dec 2, 2022
Merged
Changes from all commits
Commits
Show all changes
29 commits
Select commit Hold shift + click to select a range
df1e729
Build:Bump dependencies
yizha1 Aug 18, 2022
bcc2ea4
Build: Bump dependencies
yizha1 Aug 18, 2022
f72b2a6
Build: Bump dependencies
yizha1 Aug 18, 2022
1950096
Merge branch 'notaryproject:main' into main
yizha1 Aug 18, 2022
4b76dfc
Merge branch 'notaryproject:main' into main
yizha1 Aug 19, 2022
c0f2d12
Merge branch 'notaryproject:main' into main
yizha1 Sep 7, 2022
8735263
Merge branch 'notaryproject:main' into main
yizha1 Sep 20, 2022
7ddfebd
Merge branch 'notaryproject:main' into main
yizha1 Sep 28, 2022
75dd7aa
Merge branch 'notaryproject:main' into main
yizha1 Oct 6, 2022
94ed3c4
Merge branch 'notaryproject:main' into main
yizha1 Oct 11, 2022
0b37d70
Merge branch 'notaryproject:main' into main
yizha1 Oct 14, 2022
0a11b6d
Merge branch 'main' of https://github.com/yizha1/notation into main
yizha1 Oct 18, 2022
ac23127
Merge branch 'main' of https://github.com/yizha1/notation into main
yizha1 Oct 19, 2022
b91b4cb
Merge branch 'main' of https://github.com/yizha1/notation into main
yizha1 Oct 20, 2022
f817dfd
Merge branch 'main' of https://github.com/yizha1/notation into main
yizha1 Oct 24, 2022
3c0df15
Merge branch 'main' of https://github.com/yizha1/notation into main
yizha1 Oct 27, 2022
226c245
Merge branch 'main' of https://github.com/yizha1/notation into main
yizha1 Oct 31, 2022
cc4e2a9
Merge branch 'main' of https://github.com/yizha1/notation into main
yizha1 Nov 3, 2022
1b1afbb
Merge branch 'main' of https://github.com/yizha1/notation into main
yizha1 Nov 7, 2022
4754adb
spec: update sign cli spec for tag to digest
yizha1 Nov 8, 2022
ec8782b
spec: update digest value
yizha1 Nov 8, 2022
783c343
spec: update debug description
yizha1 Nov 8, 2022
98c9503
spec: update according to review comments
yizha1 Nov 14, 2022
3d5a887
spec: remove the changes for debug option
yizha1 Nov 18, 2022
e52a8bf
spec: update according to comments
yizha1 Nov 21, 2022
997c8dc
update typos
yizha1 Nov 24, 2022
8809288
update per comments
yizha1 Nov 28, 2022
5b18a55
update according to comments
yizha1 Dec 1, 2022
5b9e582
update according to comments
yizha1 Dec 1, 2022
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
80 changes: 57 additions & 23 deletions specs/commandline/sign.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,21 @@

Use `notation sign` to sign artifacts.

Signs an OCI artifact that is stored in a registry. Upon successful signing, the generated signature is pushed to the registry with the digest of the OCI artifact returned.
Signs an OCI artifact stored in the registry. Always sign artifact using digest(`@sha256:...`) rather than a tag(`:v1`) because tags are mutable and a tag reference can point to a different artifact than the one signed. If a tag is used, notation resolves the tag to the `digest` before signing.

Upon successful signing, the generated signature is pushed to the registry and associated with the signed OCI artifact. The output message is printed out as following:

```text
Successfully signed <registry>/<repository>@<digest>
```

If a `tag` is used to identify the OCI artifact, the output message is as following:

```test
Warning: Always sign the artifact using digest(`@sha256:...`) rather than a tag(`:<tag>`) because tags are mutable and a tag reference can point to a different artifact than the one signed.
Resolved artifact tag `<tag>` to digest `<digest>` before signing.
Successfully signed <registry>/<repository>@<digest>
```

## Outline

Expand All @@ -27,37 +41,38 @@ Flags:

## Usage

### Sign a container image
### Sign an OCI artifact

```shell
# Add a key which uses a local private key and certificate, and make it a default signing key
notation key add --default --name <key_name> <key_path> <cert_path>

# Or change the default signing key to an existing signing key
notation key update --default <key_name>
# Prerequisites:
# - A signing plugin is installed. See plugin documentation (https://github.com/notaryproject/notaryproject/blob/main/specs/plugin-extensibility.md) for more details.
yizha1 marked this conversation as resolved.
Show resolved Hide resolved
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Instead of the main branch, should we use a tag version for the URL?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can we update it later once we have cut a version for notaryproject?

# - Configure the signing plugin as instructed by plugin vendor.

# Sign a container image using the default signing key
notation sign <registry>/<repository>:<tag>
# Add a default signing key referencing the remote key identifier, and the plugin associated with it.
notation key add --default --name <key_name> --plugin <plugin_name> --id <remote_key_id>

# Or using container image digests instead of tags. A container image digest uniquely and immutably identifies a container image.
# sign an artifact stored in a registry
notation sign <registry>/<repository>@<digest>
```

### Sign a container image using a remote key
An example for a successful signing:

```console
$ notation sign localhost:5000/net-monitor@sha256:b94d27b9934d3e08a52e52d7da7dabfac484efe37a5380ee9088f7ace2efcde9
Successfully signed localhost:5000/net-monitor@sha256:b94d27b9934d3e08a52e52d7da7dabfac484efe37a5380ee9088f7ace2efcde9
```

### Sign an OCI artifact using COSE signature format

```shell
# Prerequisites:
# - A compliant signing plugin is installed in notation. See notation plugin documentation (https://github.com/notaryproject/notaryproject/blob/main/specs/plugin-extensibility.md) for more details.
# - User creates keys and certificates in a 3rd party key provider (e.g. key vault, key management service). The signing plugin installed in previous step must support generating signatures using this key provider.

# Add a default signing key referencing the key identifier for the remote key, and the plugin associated with it.
notation key add --default --name <key_name> --plugin <plugin_name> --id <remote_key_id>
# A default signing key is configured using CLI "notation key"

# sign a container image using a remote key
notation sign <registry>/<repository>:<tag>
# Use option "--signature-format" to set the signature format to COSE.
notation sign --signature-format cose <registry>/<repository>@<digest>
```

### Sign an OCI artifact using the default signing key
### Sign an OCI artifact stored in a registry using the default signing key

```shell
# Prerequisites:
Expand All @@ -67,18 +82,37 @@ notation sign <registry>/<repository>:<tag>
notation sign <registry>/<repository>@<digest>
```

### Sign a container image and specify the signature expiry duration, for example 1 day
### Sign an OCI artifact stored in a registry and specify the signature expiry duration, for example 24 hours

```shell
notation sign --expiry 1d <registry>/<repository>:<tag>
notation sign --expiry 24h <registry>/<repository>@<digest>
priteshbandi marked this conversation as resolved.
Show resolved Hide resolved
```

### Sign a container image using a specified signing key
### Sign an OCI artifact stored in a registry using a specified signing key

```shell
# List signing keys to get the key name
notation key list

# Sign a container image using the specified key name
notation sign --key <key_name> <registry>/<repository>:<tag>
notation sign --key <key_name> <registry>/<repository>@<digest>
```

### Sign an OCI artifact identified by a tag
yizha1 marked this conversation as resolved.
Show resolved Hide resolved

```shell
# Prerequisites:
# A default signing key is configured using CLI "notation key"

# Use a tag to identify a container image
notation sign <registry>/<repository>:<tag>
```

An example for a successful signing:

```console
$ notation sign localhost:5000/net-monitor:v1
Warning: Always sign the artifact using digest(`@sha256:...`) rather than a tag(`:v1`) because tags are mutable and a tag reference can point to a different artifact than the one signed.
patrickzheng200 marked this conversation as resolved.
Show resolved Hide resolved
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
Warning: Always sign the artifact using digest(`@sha256:...`) rather than a tag(`:v1`) because tags are mutable and a tag reference can point to a different artifact than the one signed.
Warning: Always sign the artifact using digest(`@sha256:...`) rather than a tag(`:<tag>`) because tags are mutable and a tag reference can point to a different artifact than the one signed.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I would keep line 115 as it is, but change the text in line 18 from :v1 to :<tag>. What do you think?

Resolved artifact tag `v1` to digest `sha256:b94d27b9934d3e08a52e52d7da7dabfac484efe37a5380ee9088f7ace2efcde9` before signing.
Successfully signed localhost:5000/net-monitor@sha256:b94d27b9934d3e08a52e52d7da7dabfac484efe37a5380ee9088f7ace2efcde9
```