1
0
Fork 0
mirror of https://github.com/moby/moby.git synced 2022-11-09 12:21:53 -05:00

Include documentation on how to add the targets/releases delegation to a repo

Signed-off-by: cyli <cyli@twistedmatrix.com>
This commit is contained in:
cyli 2016-03-18 16:11:37 -07:00
parent 623ccc2f31
commit 88d73ebff4
5 changed files with 265 additions and 25 deletions

View file

@ -108,19 +108,13 @@ $ docker pull someimage@sha256:d149ab53f8718e987c3a3024bb8aa0e2caadf6c0328f1d9d8
```
Trust for an image tag is managed through the use of signing keys. A key set is
created when an operation using content trust is first invoked. Docker's content
trust makes use of four different keys:
created when an operation using content trust is first invoked. A key set consists
of the following classes of keys:
| Key | Description |
|---------------------|---------------------------------------------------------------------------------------------------------------------------------------------------------------------|
| root key | Root of content trust for a image tag. When content trust is enabled, you create the root key once. |
| target and snapshot | These two keys are known together as the "repository" key. When content trust is enabled, you create this key when you add a new image repository. If you have the root key, you can export the repository key and allow other publishers to sign the image tags. |
| timestamp | This key applies to a repository. It allows Docker repositories to have freshness security guarantees without requiring periodic content refreshes on the client's side. |
With the exception of the timestamp, all the keys are generated and stored locally
client-side. The timestamp is safely generated and stored in a signing server that
is deployed alongside the Docker registry. All keys are generated in a backend
service that isn't directly exposed to the internet and are encrypted at rest.
- an offline key that is the root of content trust for a image tag
- repository or tagging keys that sign tags
- server-managed keys such as the timestamp key, which provides freshness
security guarantees for your repository
The following image depicts the various signing keys and their relationships:
@ -133,9 +127,9 @@ The following image depicts the various signing keys and their relationships:
>tag from this repository prior to the loss.
You should backup the root key somewhere safe. Given that it is only required
to create new repositories, it is a good idea to store it offline. Make sure you
read [Manage keys for content trust](trust_key_mng.md) information
for details on securing, and backing up your keys.
to create new repositories, it is a good idea to store it offline.
For details on securing, and backing up your keys, make sure you
read how to [manage keys for content trust](trust_key_mng.md).
## Survey of typical content trust operations
@ -302,4 +296,5 @@ $ docker push --disable-content-trust docker/trusttest:untrusted
* [Manage keys for content trust](trust_key_mng.md)
* [Automation with content trust](trust_automation.md)
* [Delegations for content trust](trust_delegation.md)
* [Play in a content trust sandbox](trust_sandbox.md)

View file

@ -17,4 +17,5 @@ The following topics are available:
* [Content trust in Docker](content_trust.md)
* [Manage keys for content trust](trust_key_mng.md)
* [Automation with content trust](trust_automation.md)
* [Delegations for content trust](trust_delegation.md)
* [Play in a content trust sandbox](trust_sandbox.md)

View file

@ -73,7 +73,8 @@ unable to process Dockerfile: No trust data for notrust
## Related information
* [Content trust in Docker](content_trust.md)
* [Content trust in Docker](content_trust.md)
* [Manage keys for content trust](trust_key_mng.md)
* [Delegations for content trust](trust_delegation.md)
* [Play in a content trust sandbox](trust_sandbox.md)

View file

@ -0,0 +1,226 @@
<!--[metadata]>
+++
title = "Delegations for content trust"
description = "Delegations for content trust"
keywords = ["trust, security, delegations, keys, repository"]
[menu.main]
parent= "smn_content_trust"
+++
<![end-metadata]-->
# Delegations for content trust
Docker Engine supports the usage of the `targets/releases` delegation as the
canonical source of a trusted image tag.
Using this delegation allows you to collaborate with other publishers without
sharing your repository key (a combination of your targets and snapshot keys -
please see "[Manage keys for content trust](trust_key_mng.md)" for more information).
A collaborator can keep their own delegation key private.
The `targest/releases` delegation is currently an optional feature - in order
to set up delegations, you must use the Notary CLI:
1. [Download the client](https://github.com/docker/notary/releases) and ensure that it is
available on your path
2. Create a configuration file at `~/.notary/config.json` with the following content:
```
{
"trust_dir" : "~/.docker/trust",
"remote_server": {
"url": "https://notary.docker.io"
}
}
```
This tells Notary where the Docker Content Trust data is stored, and to use the
Notary server used for images in Docker Hub.
For more detailed information about how to use Notary outside of the default
Docker Content Trust use cases, please refer to the
[the Notary CLI documentation](https://docs.docker.com/notary/getting_started/).
Note that when publishing and listing delegation changes using the Notary client,
your Docker Hub credentials are required.
## Generating delegation keys
Your collaborator needs to generate a private key (either RSA or ECDSA)
and give you the public key so that you can add it to the `targets/releases`
delegation.
The easiest way to for them to generate these keys is with OpenSSL.
Here is an example of how to generate a 2048-bit RSA portion key (all RSA keys
must be at least 2048 bits):
```
$ opensl genrsa -out delegation.key 2048
Generating RSA private key, 2048 bit long modulus
....................................................+++
............+++
e is 65537 (0x10001)
```
They should keep `delegation.key` private - this is what they will use to sign
tags.
Then they need to generate a x509 certificate containing the public key, which is
what they will give to you. Here is the command to generate a CSR (certificate
signing request):
```
$ openssl req -new -sha256 -key delegation.key -out delegation.csr
```
Then they can send it to whichever CA you trust to sign certificates, or they
can self-sign the certificate (in this example, creating a certificate that is
valid for 1 year):
```
$ openssl x509 -req -days 365 -in delegation.csr -signkey delegation.key -out delegation.crt
```
Then they need to give you `delegation.crt`, whether it is self-signed or signed
by a CA.
## Adding a delegation key to an existing repository
If your repository was created using a version of Docker Engine prior to 1.11,
then before adding any delegations, you should rotate the snapshot key to the server
so that collaborators will not require your snapshot key to sign and publish tags:
```
$ notary key rotate docker.io/<username>/<imagename> snapshot -r
```
This tells Notary to rotate a key for your particular image repository - note that
you must include the `docker.io/` prefix. `snapshot -r` specifies that you want
to rotate the snapshot key specifically, and you want the server to manage it (`-r`
stands for "remote").
When adding a delegation, your must acquire
[the PEM-encoded x509 certificate with the public key](#generating-delegation-keys)
of the collaborator you wish to delegate to.
Assuming you have the certificate `delegation.crt`, you can add a delegation
for this user and then publish the delegation change:
```
$ notary delegation add docker.io/<username>/<imagename> targets/releases delegation.crt --all-paths
$ notary publish docker.io/<username>/<imagename>
```
The preceding example illustrates a request to add the delegation
`targets/releases` to the image repository, if it doesn't exist. Be sure to use
`targets/releases` - Notary supports multiple delegation roles, so if you mistype
the delegation name, the Notary CLI will not error. However, Docker Engine
supports reading only from `targets/releases`.
It also adds the collaborator's public key to the delegation, enabling them to sign
the `targets/releases` delegation so long as they have the private key corresponding
to this public key. The `--all-paths` flags tells Notary not to restrict the tag
names that can be signed into `targets/releases`, which we highly recommend for
`targets/releases`.
Publishing the changes tells the server about the changes to the `targets/releases`
delegation.
After publishing, view the delegation information to ensure that you correctly added
the keys to `targets/releases`:
```
$ notary delegation list docker.io/<username>/<imagename>
ROLE PATHS KEY IDS THRESHOLD
---------------------------------------------------------------------------------------------------------------
targets/releases "" <all paths> 729c7094a8210fd1e780e7b17b7bb55c9a28a48b871b07f65d97baf93898523a 1
```
You can see the `targets/releases` with its paths and the key ID you just added.
Notary currently does not map collaborators names to keys, so we recommend
that you add and list delegation keys one at a time, and keep a mapping of the key
IDs to collaborators yourself should you need to remove a collaborator.
## Removing a delegation key from an existing repository
To revoke a collaborator's permission to sign tags for your image repository, you must
know the IDs of their keys, because you need to remove their keys from the
`targets/releases` delegation.
```
$ notary delegation remove docker.io/<username>/<imagename> targets/releases 729c7094a8210fd1e780e7b17b7bb55c9a28a48b871b07f65d97baf93898523a
Removal of delegation role targets/releases with keys [729c7094a8210fd1e780e7b17b7bb55c9a28a48b871b07f65d97baf93898523a], to repository "docker.io/<username>/<imagename>" staged for next publish.
```
The revocation will take effect as soon as you publish:
```
$ notary publish docker.io/<username>/<imagename>
```
Note that by removing all the keys from the `targets/releases` delegation, the
delegation (and any tags that are signed into it) is removed. That means that
these tags will all be deleted, and you may end up with older, legacy tags that
were signed directly by the targets key.
## Removing the `targets/releases` delegation entirely from a repository
If you've decided that delegations aren't for you, you can delete the
`targets/releases` delegation entirely. This also removes all the tags that
are currently in `targets/releases`, however, and you may end up with older,
legacy tags that were signed directly by the targets key.
To delete the `targets/releases` delegation:
```
$ notary delegation remove docker.io/<username>/<imagename> targets/releases
Are you sure you want to remove all data for this delegation? (yes/no)
yes
Forced removal (including all keys and paths) of delegation role targets/releases to repository "docker.io/<username>/<imagename>" staged for next publish.
$ notary publish docker.io/<username>/<imagename>
```
## Pushing trusted data as a collaborator
As a collaborator with a private key that has been added to a repository's
`targets/releases` delegation, you need to import the private key that you
generated into Content Trust.
To do so, you can run:
```
$ notary key import delegation.key --role user
```
where `delegation.key` is the file containing your PEM-encoded private key.
After you have done so, running `docker push` on any repository that
includes your key in the `targets/releases` delegation will automatically sign
tags using this imported key.
## `docker push` behavior
When running `docker push` with Docker Content Trust, Docker Engine
will attempt to sign and push with the `targets/releases` delegation if it exists.
If it does not, the targets key will be used to sign the tag, if the key is available.
## `docker pull` and `docker build` behavior
When running `docker pull` or `docker build` with Docker Content Trust, Docker
Engine will pull tags only signed by the `targets/releases` delegation role or
the legacy tags that were signed directly with the `targets` key.
## Related information
* [Content trust in Docker](content_trust.md)
* [Manage keys for content trust](trust_key_mng.md)
* [Automation with content trust](trust_automation.md)
* [Play in a content trust sandbox](trust_sandbox.md)

View file

@ -11,18 +11,34 @@ parent= "smn_content_trust"
# Manage keys for content trust
Trust for an image tag is managed through the use of keys. Docker's content
trust makes use four different keys:
trust makes use of five different types of keys:
| Key | Description |
|---------------------|---------------------------------------------------------------------------------------------------------------------------------------------------------------------|
| root key | Root of content trust for a image tag. When content trust is enabled, you create the root key once. |
| target and snapshot | These two keys are known together as the "repository" key. When content trust is enabled, you create this key when you add a new image repository. If you have the root key, you can export the repository key and allow other publishers to sign the image tags. |
| timestamp | This key applies to a repository. It allows Docker repositories to have freshness security guarantees without requiring periodic content refreshes on the client's side. |
| root key | Root of content trust for a image tag. When content trust is enabled, you create the root key once. Also known as the offline key, because it should be kept offline. |
| targets | This key allows you to sign image tags, to manage delegations including delegated keys or permitted delegation paths. Also known as the repository key, since this key determines what tags can be signed into an image repository. |
| snapshot | This key signs the current collection of image tags, preventing mix and match attacks.
| timestamp | This key allows Docker image repositories to have freshness security guarantees without requiring periodic content refreshes on the client's side. |
| delegation | Delegation keys are optional tagging keys and allow you to delegate signing image tags to other publishers without having to share your targets key. |
With the exception of the timestamp, all the keys are generated and stored locally
client-side. The timestamp is safely generated and stored in a signing server that
is deployed alongside the Docker registry. All keys are generated in a backend
service that isn't directly exposed to the internet and are encrypted at rest.
When doing a `docker push` with Content Trust enabled for the first time, the
root, targets, snapshot, and timestamp keys are generated automatically for
the image repository:
- The root and targets key are generated and stored locally client-side.
- The timestamp and snapshot keys are safely generated and stored in a signing server
that is deployed alongside the Docker registry. These keys are generated in a backend
service that isn't directly exposed to the internet and are encrypted at rest.
Delegation keys are optional, and not generated as part of the normal `docker`
workflow. They need to be
[manually generated and added to the repository](trust_delegation.md#generating-delegation-keys).
Note: Prior to Docker Engine 1.11, the snapshot key was also generated and stored
locally client-side. [Use the Notary CLI to manage your snapshot key locally
again](https://docs.docker.com/notary/advanced_usage/#rotate-keys) for
repositories created with newer versions of Docker.
## Choosing a passphrase
@ -68,6 +84,7 @@ the new key.
## Related information
* [Content trust in Docker](content_trust.md)
* [Content trust in Docker](content_trust.md)
* [Automation with content trust](trust_automation.md)
* [Delegations for content trust](trust_delegation.md)
* [Play in a content trust sandbox](trust_sandbox.md)