コンテントトラストにおける鍵の管理

読む時間の目安: 3 分

イメージタグに対する信頼(trust)は、鍵を利用することによって管理します。 Docker のコンテントトラストは 5 種類の鍵を利用します。

内容説明
ルート Root of content trust for an 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.
ターゲット 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.
スナップショット This key signs the current collection of image tags, preventing mix and match attacks.
タイムスタンプ 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.

コンテントトラストを有効にした状態で、初めてdocker pushを実行すると、そのイメージリポジトリに対して、ルート、ターゲット、スナップショット、タイムスタンプの各鍵が自動生成されます。

  • ルート鍵とターゲット鍵が生成されると、クライアントサイドにローカルに保存されます。

  • タイムスタンプ鍵とスナップショット鍵は Docker レジストリと並んでデプロイされる認証サーバー内に、安全に生成され保存されます。 これらの鍵はバックエンドサービスにより生成されるものであり、インターネット上に直接公開されることはなく、安全に暗号化されます。

委任鍵はオプションであって、dockerの通常処理の中では生成されません。 これには 手動生成とリポジトリへの追加 が必要になります。

メモ Docker Engine 1.11 より前のバージョンでは、スナップショット鍵もクライアントサイドにローカルに保存されていました。 Use the Notary CLI to manage your snapshot key locally again for repositories created with newer versions of Docker.

パスフレーズの決定

The passphrases you chose for both the root key and your repository key should be randomly generated and stored in a password manager. Having the repository key allows users to sign image tags on a repository. Passphrases are used to encrypt your keys at rest and ensure that a lost laptop or an unintended backup doesn’t put the private key material at risk.

鍵のバックアップ

All the Docker trust keys are stored encrypted using the passphrase you provide on creation. Even so, you should still take care of the location where you back them up. Good practice is to create two encrypted USB keys.

It is very important that you back up your keys to a safe, secure location. Loss of the repository key is recoverable; loss of the root key is not.

The Docker client stores the keys in the ~/.docker/trust/private directory. Before backing them up, you should tar them into an archive:

$ umask 077; tar -zcvf private_keys_backup.tar.gz ~/.docker/trust/private; umask 022

Hardware storage and signing

Docker Content Trust can store and sign with root keys from a Yubikey 4. The Yubikey is prioritized over keys stored in the filesystem. When you initialize a new repository with content trust, Docker Engine looks for a root key locally. If a key is not found and the Yubikey 4 exists, Docker Engine creates a root key in the Yubikey 4. Consult the Notary documentation for more details.

Docker Engine 1.11 より前のバージョンにおいてこの機能は、試験用ブランチからのみ提供されています。

鍵の紛失

イメージの公開者が鍵を失うということは、リポジトリ内のコンテントデータにサインできなくなるということです。 鍵を紛失したときは Docker Hub サポート にメールで連絡してください。 リポジトリのリセット操作を行います。 state.

鍵の紛失してしまうと、紛失以前のタグイメージをプルしていたユーザーは、全員が 手動で復旧操作を行う 必要があります。 イメージ利用者がすでにイメージをダウンロードしてしまっているときには、エラーが発生します。

Warning: potential malicious behavior - trust data has insufficient signatures for remote repository docker.io/my/image: valid signatures did not meet threshold

エラー復旧するには、新たな鍵によって正しくサインされた、新しいイメージをダウンロードすることが必要です。

trust, security, root, keys, repository