为什么 swarm-node.key 有两个键

Why swarm-node.key has two keys

根据 this 文章,我了解到该文件保存着用于加密 Raft 日志并确保节点之间安全 TLS 通信的私钥。

这是文件:/var/lib/docker/swarm/certificates/swarm-node.key
查看其内容:

它似乎有两个部分。
第一个(标有绿色的)是筏板。
根据 this 文章:

On manager hosts secrets are always encrypted at rest. By default, the key that encrypts these secrets (known as the Data Encryption Key, DEK) is also stored in plaintext on disk.

第二个键是什么?它是负责加密 Raft 日志的密钥吗?

是的,这个文件包含两个键:

  1. 加密秘密
  2. 将数据加密到 Raft

有两种数据需要加密:

  1. 节点之间的一般流量数据。
  2. 敏感机密。

节点之间的流量数据通过TLS加密。 swarm 使用 MTLS 来保护节点之间的通信。

敏感机密由 DEK 加密。

这个swarm-node.key文件只包含一个私钥,这是TLS中使用的密钥。该文件由两部分构成:header 部分和 body 部分。 body 部分携带实际的私钥。而 header 部分可以携带额外的信息。在这种情况下,DEK 位于 header 部分。

Source code:

// the raft DEK (data encryption key) is stored in the TLS key as a header
// these are the header values
pemHeaderRaftDEK              = "raft-dek"
...