-
Notifications
You must be signed in to change notification settings - Fork 92
hello signing samples #78
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
Changes from all commits
1db7a79
bd6054b
f1ea87a
531a109
9b64000
7c71436
82ee7c5
2a8948a
fc647a1
2994eb2
afdd977
bdfcfdb
a64c494
66f09d3
4b13f24
bce3ef0
37bc552
a97b086
21e7981
9dc8fda
20d1717
401b440
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,145 @@ | ||
| # Hello World for Notation | ||
|
|
||
| To get started with Notation, the most basic steps involve: | ||
|
|
||
| - Acquire the Notation CLI | ||
| - Generate a Private Key | ||
| - Sign an Artifact | ||
| - Verify an Artifact with a Notary Signature | ||
|
|
||
| This document outlines a range of scenarios progressing from the first use of Notation to a production deployment. | ||
|
|
||
| ## Scenarios | ||
|
|
||
| To demonstrate how to store and sign a set of supply chain artifacts, we will walk through a set of scenarios: | ||
| - Sign a single container image | ||
| - Publish the container image across public registries, | ||
| - Import public content to a private registry | ||
| - Promote from dev through production | ||
|
|
||
|  | ||
|
|
||
| To illustrate these scenarios we will introduce two example companies: | ||
|
|
||
| - **Wabbit Networks**: A small software company that produces network monitoring software | ||
| - **ACME Rockets**: A consumer, who runs network monitoring software | ||
|
|
||
| ACME Rockets doesn't know about Wabbit Networks, but finds their [net-monitor software in Docker Hub](https://hub.docker.com/r/wabbitnetworks/net-monitor). | ||
| Since they've never heard of Wabbit Networks, they're a little reluctant to run network software without some validations. | ||
| ACME Rockets has a policy to only import Docker Hub certified content, and other approved vendors. | ||
|
|
||
| Wabbit Networks works with Docker Hub to get certified, to help with their customer confidence. | ||
|
|
||
| ACME Rockets will only deploy software that's been scanned and approved by the ACME Rockets security team. They know it's been approved because all approved software has been signed by the ACME Rockets security team. | ||
|
|
||
| ## Getting Started | ||
| - Setup a few environment variables. | ||
SteveLasker marked this conversation as resolved.
Show resolved
Hide resolved
|
||
| >Note see [Simulating a Registry DNS Name](#simulating-a-registry-dns-name) to use `registry.wabbit-networks.io` | ||
| ```bash | ||
| export PORT=5000 | ||
| export REGISTRY=localhost:${PORT} | ||
| export REPO=${REGISTRY}/net-monitor | ||
| export IMAGE=${REPO}:v1 | ||
SteveLasker marked this conversation as resolved.
Show resolved
Hide resolved
|
||
| ``` | ||
| - Install [Docker Desktop](https://www.docker.com/products/docker-desktop) for local docker operations | ||
| - Run a local instance of the [CNCF Distribution Registry][cncf-distribution] | ||
| ```bash | ||
| docker run -d -p ${PORT}:5000 ghcr.io/oras-project/registry:latest | ||
| ``` | ||
| - Acquire the Notation CLI | ||
| Notation releases can be found at: [Notation Releases][notation-releases] | ||
| ```bash | ||
| #LINUX, including WSL | ||
| curl -Lo notation.tar.gz https://github.com/shizhMSFT/notation/releases/download/v0.5.2/notation_0.5.2_linux_amd64.tar.gz | ||
| tar xvzf notation.tar.gz -C ~/bin notation | ||
| ``` | ||
|
|
||
| ## Building and Pushing | ||
| - Build and Push the `net-monitor` software | ||
SteveLasker marked this conversation as resolved.
Show resolved
Hide resolved
|
||
| ```bash | ||
| docker build -t $IMAGE https://github.com/wabbit-networks/net-monitor.git#main | ||
|
|
||
| docker push $IMAGE | ||
| ``` | ||
| - List the image, and any associated signatures | ||
| ```bash | ||
| notation list $IMAGE | ||
| ``` | ||
| At this point, the results are empty, as there are no existing signatures | ||
|
|
||
| ## Signing a Container Image | ||
|
|
||
| To get things started quickly, the Notation cli supports generating self signed certificates. As you automate the signing of content, you will most likely want to create and store the private keys in a key vault. (Detailed production steps will be covered later) | ||
|
|
||
| - Generate a self-signed test certificate for signing artifacts | ||
| The following will generate a self-signed X.509 certificate under the `~/config/notation/` directory | ||
| ```bash | ||
| notation cert generate-test --default "wabbit-networks.io" | ||
| ``` | ||
| - Sign the container image | ||
| ```bash | ||
| notation sign $IMAGE | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I'd prefer being explicit about the key being used and not using a default, we can address that later.
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. We did want to enable the simple/default scenarios but appreciate the concern.
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Opened #91 |
||
| ``` | ||
| - List the image, and any associated signatures | ||
| ```bash | ||
| notation list $IMAGE | ||
| ``` | ||
|
|
||
| ## Verify a Container Image Using Notation Signatures | ||
|
|
||
| To avoid a Trojan Horse attack, and before pulling an artifact into an environment, it is important to verify that the artifact was unmodified after it was created (integrity), and from an trusted entity (authenticity). Notation uses a set of configured public keys that represent trusted entities, to verify the content. The `notation cert generate-test` command created the public key, however it must be implicitly added for verification to succeed. | ||
| - Attempt to verify the $IMAGE notation signature | ||
| ```bash | ||
| notation verify $IMAGE | ||
| ``` | ||
| *The above verification should fail, as you haven't yet configured the keys to trust.* | ||
SteveLasker marked this conversation as resolved.
Show resolved
Hide resolved
|
||
| ```bash | ||
| 2021/09/07 11:40:51 trust certificate not specified | ||
| ``` | ||
| - To assure users opt-into the public keys they trust, add the key to the trusted store | ||
| ```bash | ||
| notation cert add --name "wabbit-networks.io" ~/.config/notation/certificate/wabbit-networks.io.crt | ||
| ``` | ||
| - Verify the `net-monitor:v1` notation signature | ||
| ```bash | ||
| notation verify $IMAGE | ||
| ``` | ||
| This should now succeed because the image is signed with a trusted public key | ||
|
|
||
| ## Reset | ||
| To resetting the environment | ||
|
|
||
| - Remove keys, certificates and notation `config.json` | ||
| `rm -r ~/.config/notation/` | ||
| - Restart the local registry | ||
| `docker rm -f $(docker ps -q)` | ||
|
|
||
| ## Simulating a Registry DNS Name | ||
|
|
||
| Here are the additional steps to simulate a fully qualified DNS name for wabbit-networks. | ||
|
|
||
| - Setup names and variables for `registry.wabbit-networks.io` | ||
| ```bash | ||
| export PORT=80 | ||
| export REGISTRY=registry.wabbit-networks.io | ||
| export REPO=${REGISTRY}/net-monitor | ||
| export IMAGE=${REPO}:v1 | ||
| ``` | ||
| - Edit `~/.config/notation/config.json` to support local, insecure registries | ||
| ```json | ||
| { | ||
| "insecureRegistries": [ | ||
| "registry.wabbit-networks.io" | ||
| ] | ||
| } | ||
| ``` | ||
| - Add a `etc/hosts` entry to simulate pushing to registry.wabbit-networks.io | ||
| - If running on windows, _even if using wsl_, add the following entry to: `C:\Windows\System32\drivers\etc\hosts` | ||
| ```hosts | ||
| 127.0.0.1 registry.wabbit-networks.io | ||
| ``` | ||
| - Continue with [Getting Started](#getting-started), but skip the environment variable configurations | ||
|
|
||
| [notation-releases]: https://github.com/shizhMSFT/notation/releases/tag/v0.5.0 | ||
| [artifact-manifest]: https://github.com/oras-project/artifacts-spec/blob/main/artifact-manifest.md | ||
| [cncf-distribution]: https://github.com/oras-project/distribution | ||
Uh oh!
There was an error while loading. Please reload this page.