需要的建议:如何正确处理用于加密容器间通信的自签名 ssl 证书+密钥对?
Advice needed: How to correctly handle self-signed ssl cert+key pairs for encrypting inter-container communication?
可能是一些相当菜鸟的问题,但我四处搜索但未能找出处理自签名证书(从 opsec 的角度来看)以加密 docker 化服务之间的通信的最佳方法在我的 Debian 服务器上,如 Redis、Authelia、Portainer 等?
证书已创建并签署,所有相关容器都已准备好用于证书密钥对的主机安装卷。
所以问题很简单:
- 我是否只将证书密钥对存储在已经安装到容器的文件夹中,例如
/docker/appdata/portainer/config
?
- 谁应该是证书+密钥对的 owner:group,root 或用户 运行 容器或第三者?
- 应该为证书+密钥对设置哪些权限?
顺便说一句。我的 docker 设置为单节点集群,所有容器都使用堆栈部署部署并使用自定义 docker 桥接网络正确地彼此连接并且通信正常,所以我的问题仅与处理有关证书+密钥对
非常感谢...
Do I just store the cert-key pairs in the folders already mounted to the containers like e.g. /docker/appdata/portainer/config?
我建议使用 docker secrets. You have the option of creating secrets with docker secret create
或从主机上的文件加载它们。例如
version: '3.9'
services:
app:
image: ubuntu
secrets:
- source: my-cert
target: /certs/my-cert.crt # Load it into /certs/my-cert.crt, default is /run/secrets/{secret_name}
mode: 0400 # Read only by owner, default is 444
# uid: '0' # Default UID is root, change if needed.
# gid: '0' # Default GID is root, change if needed.
- source: my-other-cert
target: /certs/my-other-cert.crt
mode: 0400
secrets:
my-cert:
external: true # Load cert from a secret made with "docker secret create"
my-other-cert:
file: ./some-cert.crt # Load cert from a file on your host machine
Who should be the owner:group of the certs+keys pairs, root or the user running the container or something third?
几乎可以肯定是 root,除非它是容器内的另一个用户 运行。您可以通过机密的 uid
和 gid
选项进行配置。
Which permissions should be set for the certs+key pairs?
一般情况下,您需要 400
或 444
。使用秘密还有一个额外的好处,那就是使这些文件无法从容器中写入(甚至是根目录)。您可以使用机密的 mode
选项进行配置。
如果您要从磁盘上的文件而不是使用 docker secret create
加载秘密,它应该来自所有 swarm 节点都可以访问的共享存储。我知道你说它是一群,只是为了清楚起见添加的。
可能是一些相当菜鸟的问题,但我四处搜索但未能找出处理自签名证书(从 opsec 的角度来看)以加密 docker 化服务之间的通信的最佳方法在我的 Debian 服务器上,如 Redis、Authelia、Portainer 等?
证书已创建并签署,所有相关容器都已准备好用于证书密钥对的主机安装卷。
所以问题很简单:
- 我是否只将证书密钥对存储在已经安装到容器的文件夹中,例如
/docker/appdata/portainer/config
? - 谁应该是证书+密钥对的 owner:group,root 或用户 运行 容器或第三者?
- 应该为证书+密钥对设置哪些权限?
顺便说一句。我的 docker 设置为单节点集群,所有容器都使用堆栈部署部署并使用自定义 docker 桥接网络正确地彼此连接并且通信正常,所以我的问题仅与处理有关证书+密钥对
非常感谢...
Do I just store the cert-key pairs in the folders already mounted to the containers like e.g. /docker/appdata/portainer/config?
我建议使用 docker secrets. You have the option of creating secrets with docker secret create
或从主机上的文件加载它们。例如
version: '3.9'
services:
app:
image: ubuntu
secrets:
- source: my-cert
target: /certs/my-cert.crt # Load it into /certs/my-cert.crt, default is /run/secrets/{secret_name}
mode: 0400 # Read only by owner, default is 444
# uid: '0' # Default UID is root, change if needed.
# gid: '0' # Default GID is root, change if needed.
- source: my-other-cert
target: /certs/my-other-cert.crt
mode: 0400
secrets:
my-cert:
external: true # Load cert from a secret made with "docker secret create"
my-other-cert:
file: ./some-cert.crt # Load cert from a file on your host machine
Who should be the owner:group of the certs+keys pairs, root or the user running the container or something third?
几乎可以肯定是 root,除非它是容器内的另一个用户 运行。您可以通过机密的 uid
和 gid
选项进行配置。
Which permissions should be set for the certs+key pairs?
一般情况下,您需要 400
或 444
。使用秘密还有一个额外的好处,那就是使这些文件无法从容器中写入(甚至是根目录)。您可以使用机密的 mode
选项进行配置。
如果您要从磁盘上的文件而不是使用 docker secret create
加载秘密,它应该来自所有 swarm 节点都可以访问的共享存储。我知道你说它是一群,只是为了清楚起见添加的。