使用 CACLI 轮换更新 Unseal Key
适用场景
在某些情况下,您可能希望重新生成 CA 授权密钥分片,即轮换更新 Unseal Key,比如:
- CA 管理员有变动
- 需要调整密钥分片的数量及管理门限
- 安全要求,需要定期更换 CA 授权密钥分片
准备工作
在进行首次部署 CA 集群时,需要完成以下准备:
| 准备项 | 准备结果示例 |
| 起因 | 定期更新 CA 授权密钥分片 |
| 确认 CA 集群实例数量 | 2 |
| 确认 rekey 前的管理员人员和管理门限 | 确认 Admin1、Admin2、Admin3 三位管理员参与管理,管理门限 2/3 |
| 确认 rekey 后新的的管理员人员和管理门限 | 确认 Admin1、Admin2、Admin3 三位管理员参与管理,管理门限 2/3 |
| 确认运维人员 | 确认由运维人员 OP 运维和部署 CA 集群 |
操作步骤
操作步骤概述
1、OP 准备 CA 和 CACLI 机器和环境
2、Admin 合作完成 CA rekey
3、OP 重启集群中其他 CA 节点
4、OP 进行资源清理收尾工作
OP 准备 CACLI 机器和环境
1、OP 准备 CACLI1 、CACLI2、CACLI3、CACLI-OP 四台机器,分别用于 Admin1、Admin2、Admin3、OP 执行 CACLI 命令,每个 Admin 使用各自的机器执行命令;OP 在所有机器上准备好 Docker 环境、smn-ca Docker 镜像
2、OP 根据《SMN CACLI 部署》文档分别在 CACLI1、CACLI2、CACLI3、CACLI-OP 机器上部署好 CACLI,并执行下面命令验证 CACLI 可正常使用,其中 CA_ADDR 环境变量中的 IP 设置为 CA Server1 的主机 IP,需要注意,镜像仓库地址 registry.docker.com/smn/smn-ca 应该修改为开发者内网仓库地址,smn-ca 版本 X.Y.Z 修改为当前使用或者最新的 ca 版本
$ docker run \
-it \
--rm \
--name mpcca-cli \
-e "CA_ADDR=http://CA Server1's IP:8090" \
-v /etc/sgx_default_qcnl.conf:/etc/sgx_default_qcnl.conf \
registry.gitlab.com/safeheron-mpc-node/smn/smn-ca:X.Y.Z \
cacli status
-------------------- Output Example --------------------
CA Status: Authorized
Seal Type: Shamir
Total Shares: 3
Threshold: 2
Version: 1.1.0
Root Key Hash: 1b06962e****5af01edf
MRENCLAVE: a9408284******23f5643
MRENCLAVE_SIG: business******de1003、OP 准备必要的信息分别发送给三位 Admin,信息包括:
- 如何连接和使用 CACLI1、CACLI2、CACLI3 服务器,SSH 凭证或者云服务厂商凭证
- 通过 Docker 使用 CACLI 的命令,写好环境变量、镜像地址、镜像版本、需要执行的命令等,减少 Admin 操作步骤和复杂度,比如准备好以下信息,只需要管理员复制粘贴即可:
docker run \
-it \
--rm \
--name mpcca-cli \
-e "CA_ADDR=http://192.168.0.100:8090" \
-v /etc/sgx_default_qcnl.conf:/etc/sgx_default_qcnl.conf \
registry.docker.com/smn/smn-ca:1.1.0 \
cacli admin rekey --key-shares=replace-me --key-threshold=replace-me
docker run \
-it \
--rm \
--name mpcca-cli \
-e "CA_ADDR=http://192.168.0.100:8090" \
-v /etc/sgx_default_qcnl.conf:/etc/sgx_default_qcnl.conf \
registry.docker.com/smn/smn-ca:1.1.0 \
cacli admin rekey --input --nonce=replace-me
docker run \
-it \
--rm \
--name mpcca-cli \
-e "CA_ADDR=http://192.168.0.100:8090" \
-v /etc/sgx_default_qcnl.conf:/etc/sgx_default_qcnl.conf \
registry.docker.com/smn/smn-ca:1.1.0 \
cacli admin rekey --backup --nonce=replace-me
docker run \
-it \
--rm \
--name mpcca-cli \
-e "CA_ADDR=http://192.168.0.100:8090" \
-v /etc/sgx_default_qcnl.conf:/etc/sgx_default_qcnl.conf \
registry.docker.com/smn/smn-ca:1.1.0 \
cacli admin rekey --verify --nonce=replace-me- 整理一份适合内部使用的操作文档,供 Admin 参考使用
Admin 合作完成 CA rekey
1、Admin1 登录 CACLI1 执行以下命令,启动密钥分片轮换更新任务,执行命令后在提示处输入备份的授权密钥分片并回车,把命令输出的CA Rekey Operation Nonce: 0a050797-6664-43a7-a2a3-ee31deaa7ae5发送给 Admin2 和 Admin3,并通知 Admin2 和 Admin3 进行 rekey 操作
$ docker run \
-it \
--rm \
--name mpcca-cli \
-e "CA_ADDR=http://192.168.0.100:8090" \
-v /etc/sgx_default_qcnl.conf:/etc/sgx_default_qcnl.conf \
registry.gitlab.com/safeheron-mpc-node/smn/smn-ca:1.1.0 \
cacli admin rekey --key-shares=3 --key-threshold=2
-------------------- Input Tips ------------------------
Please input your **CURRENT** unseal key(Input will be hidden, and type Enter to confirm input. The nonce of the current operation is '0a050797-6664-43a7-a2a3-ee31deaa7ae5'): <CURRENT Unseal Key>
-------------------- Output Example --------------------
Seal Type: Shamir
CA Rekey Operation Nonce: 0a050797-6664-43a7-a2a3-ee31deaa7ae5
Total Shares: 3
Threshold: 2
Modified Total Shares: 3
Modified Threshold: 2
-> Input Progress: 1/2
Input Validation Success: unfinished
Backup Progress: 0/3
Backup Finished: false
Verify Progress: 0/3
Verify Success: unfinished2、Admin2 登录 CACLI2 执行以下命令,执行命令后在提示处输入备份的授权密钥分片并回车,并确保输出的Input Validation Success为 true。命令参数--nonce 的值为 Admin1 提供的 CA Unseal Operation Nonce
$ docker run \
-it \
--rm \
--name mpcca-cli \
-e "CA_ADDR=http://192.168.0.100:8090" \
-v /etc/sgx_default_qcnl.conf:/etc/sgx_default_qcnl.conf \
registry.gitlab.com/safeheron-mpc-node/smn/smn-ca:1.1.0 \
cacli admin rekey --input --nonce=0a050797-6664-43a7-a2a3-ee31deaa7ae5
-------------------- Input Tips ------------------------
Please input your **CURRENT** unseal key(Input will be hidden, and type Enter to confirm input. The nonce of the current operation is '0a050797-6664-43a7-a2a3-ee31deaa7ae5'): <CURRENT Unseal Key>
-------------------- Output Example --------------------
Seal Type: Shamir
CA Rekey Operation Nonce: 0a050797-6664-43a7-a2a3-ee31deaa7ae5
Total Shares: 3
Threshold: 2
Modified Total Shares: 3
Modified Threshold: 2
-> Input Progress: 2/2
Input Validation Success: true
Backup Progress: 0/3
Backup Finished: false
Verify Progress: 0/3
Verify Success: unfinished当Input Validation Success为true时,表明 Admin1,Admin2 均已完输入之前备份的密钥分片且正确无误,CA 已经根据新设置的密钥分片数量和门限生成了一组新的但尚未生效的 Unseal Key,当所有 CA 管理员按以下说明完成 backup 和 verify 操作后, 新的 Unseal Key 生效。
3、Admin1 执行以下命令,获取一片新的授权密钥分片并妥善备份,其中nonce值为 CA Unseal Operation Nonce
$ docker run \
-it \
--rm \
--name mpcca-cli \
-e "CA_ADDR=http://192.168.0.100:8090" \
-v /etc/sgx_default_qcnl.conf:/etc/sgx_default_qcnl.conf \
registry.gitlab.com/safeheron-mpc-node/smn/smn-ca:1.1.0 \
cacli admin rekey --backup --nonce=0a050797-6664-43a7-a2a3-ee31deaa7ae5
-------------------- Output Example --------------------
Seal Type: Shamir
CA Rekey Operation Nonce: 0a050797-6664-43a7-a2a3-ee31deaa7ae5
Total Shares: 3
Threshold: 2
Modified Total Shares: 3
Modified Threshold: 2
Input Progress: 2/2
Input Validation Success: true
-> Backup Progress: 1/3
Backup Finished: false
Verify Progress: 0/3
Verify Success: unfinished
Unseal Key: uk1.pmYTf6u3hczA196plQvnCObxJanAMGz3walxmqjBYZY=
...
4、Admin2 执行以下命令,获取一片新的授权密钥分片并妥善备份,其中nonce值为CA Unseal Operation Nonce
$ docker run \
-it \
--rm \
--name mpcca-cli \
-e "CA_ADDR=http://192.168.0.100:8090" \
-v /etc/sgx_default_qcnl.conf:/etc/sgx_default_qcnl.conf \
registry.gitlab.com/safeheron-mpc-node/smn/smn-ca:1.1.0 \
cacli admin rekey --backup --nonce=0a050797-6664-43a7-a2a3-ee31deaa7ae5
-------------------- Output Example --------------------
Seal Type: Shamir
CA Rekey Operation Nonce: 0a050797-6664-43a7-a2a3-ee31deaa7ae5
Total Shares: 3
Threshold: 2
Modified Total Shares: 3
Modified Threshold: 2
Input Progress: 2/2
Input Validation Success: true
-> Backup Progress: 2/3
Backup Finished: false
Verify Progress: 0/3
Verify Success: unfinished
Unseal Key: uk2.QtLjq+pkEHZBk3Es0p8ruFK7ITOlvANAEJETZbAZcSk=
...
5、Admin3 执行以下命令,获取最后一片新的授权密钥分片并妥善备份,其中nonce值为CA Unseal Operation Nonce
$ docker run \
-it \
--rm \
--name mpcca-cli \
-e "CA_ADDR=http://192.168.0.100:8090" \
-v /etc/sgx_default_qcnl.conf:/etc/sgx_default_qcnl.conf \
registry.gitlab.com/safeheron-mpc-node/smn/smn-ca:1.1.0 \
cacli admin rekey --backup --nonce=0a050797-6664-43a7-a2a3-ee31deaa7ae5
-------------------- Output Example --------------------
Seal Type: Shamir
CA Rekey Operation Nonce: 0a050797-6664-43a7-a2a3-ee31deaa7ae5
Total Shares: 3
Threshold: 2
Modified Total Shares: 3
Modified Threshold: 2
Input Progress: 2/2
Input Validation Success: true
-> Backup Progress: 3/3
Backup Finished: true
Verify Progress: 0/3
Verify Success: unfinished
Unseal Key: uk3.3z+z1ykQmyDCTwOwEDJwZ3tsF2syXzgNUzJ/87PUpg0=
...当Backup Finished为true时,表明所有 CA 管理员均各自获取并备份了一片密钥分片,接下来需要进行 verify 操作。
6、Admin1 执行以下命令验证自己备份的新密钥分片,其中 nonce 值为CA Unseal Operation Nonce
$ docker run \
-it \
--rm \
--name mpcca-cli \
-e "CA_ADDR=http://192.168.0.100:8090" \
-v /etc/sgx_default_qcnl.conf:/etc/sgx_default_qcnl.conf \
registry.gitlab.com/safeheron-mpc-node/smn/smn-ca:1.1.0 \
cacli admin rekey --verify --nonce=0a050797-6664-43a7-a2a3-ee31deaa7ae5
-------------------- Input Tips ------------------------
Please input your **NEW** unseal key(Input will be hidden, and type Enter to confirm input. The nonce of the current operation is '3eaf93f5-d86a-4ad1-8118-5f6fff6254c3'): <NEW Unseal Key>
-------------------- Output Example --------------------
Seal Type: Shamir
CA Rekey Operation Nonce: 0a050797-6664-43a7-a2a3-ee31deaa7ae5
Total Shares: 3
Threshold: 2
Modified Total Shares: 3
Modified Threshold: 2
Input Progress: 2/2
Input Validation Success: true
Backup Progress: 3/3
Backup Finished: true
-> Verify Progress: 1/3
Verify Success: unfinished
7、Admin2 执行以下命令验证自己备份的新密钥分片,其中 nonce 值为CA Unseal Operation Nonce
$ docker run \
-it \
--rm \
--name mpcca-cli \
-e "CA_ADDR=http://192.168.0.100:8090" \
-v /etc/sgx_default_qcnl.conf:/etc/sgx_default_qcnl.conf \
registry.gitlab.com/safeheron-mpc-node/smn/smn-ca:1.1.0 \
cacli admin rekey --verify --nonce=0a050797-6664-43a7-a2a3-ee31deaa7ae5
-------------------- Input Tips ------------------------
Please input your **NEW** unseal key(Input will be hidden, and type Enter to confirm input. The nonce of the current operation is '3eaf93f5-d86a-4ad1-8118-5f6fff6254c3'): <NEW Unseal Key>
-------------------- Output Example --------------------
Seal Type: Shamir
CA Rekey Operation Nonce: 0a050797-6664-43a7-a2a3-ee31deaa7ae5
Total Shares: 3
Threshold: 2
Modified Total Shares: 3
Modified Threshold: 2
Input Progress: 2/2
Input Validation Success: true
Backup Progress: 3/3
Backup Finished: true
-> Verify Progress: 2/3
Verify Success: unfinished
8、Admin3 执行以下命令验证自己备份的新密钥分片,其中 nonce 值为CA Unseal Operation Nonce
$ docker run \
-it \
--rm \
--name mpcca-cli \
-e "CA_ADDR=http://192.168.0.100:8090" \
-v /etc/sgx_default_qcnl.conf:/etc/sgx_default_qcnl.conf \
registry.gitlab.com/safeheron-mpc-node/smn/smn-ca:1.1.0 \
cacli admin rekey --verify --nonce=0a050797-6664-43a7-a2a3-ee31deaa7ae5
-------------------- Input Tips ------------------------
Please input your **NEW** unseal key(Input will be hidden, and type Enter to confirm input. The nonce of the current operation is '3eaf93f5-d86a-4ad1-8118-5f6fff6254c3'): <NEW Unseal Key>
-------------------- Output Example --------------------
Seal Type: Shamir
CA Rekey Operation Nonce: 0a050797-6664-43a7-a2a3-ee31deaa7ae5
Total Shares: 3
Threshold: 2
Modified Total Shares: 3
Modified Threshold: 2
Input Progress: 2/2
Input Validation Success: true
Backup Progress: 3/3
Backup Finished: true
-> Verify Progress: 3/3
Verify Success: true当Verify Success为true时,表明所有 CA 管理员(此示例为 Admin1,Admin2,Admin3 )均已完成 rekey 操作并妥善备份新的 Unseal Key,且已经验证了备份的新的 Unseal Key 正确无误,新的 Unseal Key 生效,旧的 Unseal Key 失效。rekey 操作完成,通知 OP 继续下个步骤。
OP 同步 rekey 操作到集群中其他 CA 节点
1、OP 登录 CACLI-OP 执行以下命令,其中 CA_ADDR 环境变量中的 IP 设置为 CA Server1 的主机 IP,确认 CA Server1 密钥轮换更新任务完成,即从命令输出中确认以下两处:
- 命令输出的
CA Rekey Operation Nonce前缀与 CA 管理员一致
- 命令输出的
Verify success为 true
$ docker run \
-it \
--rm \
--name mpcca-cli \
-e "CA_ADDR=http://CA Server1's IP:8090" \
-v /etc/sgx_default_qcnl.conf:/etc/sgx_default_qcnl.conf \
registry.gitlab.com/safeheron-mpc-node/smn/smn-ca:1.1.0 \
cacli admin rekey --status
-------------------- Output Example --------------------
Seal Type: Shamir
CA Rekey Operation Nonce: 0a050797****************************
Total Shares: 3
Threshold: 2
Modified Total Shares: 3
Modified Threshold: 2
Input Progress: 2/2
Input Validation Success: true
Backup Progress: 3/3
Backup Finished: true
-> Verify Progress: 3/3
Verify Success: true2、OP 登录 CACLI-OP 执行以下命令,记录命令输出的Root Key Hash
$ docker run \
-it \
--rm \
--name mpcca-cli \
-e "CA_ADDR=http://CA Server1's IP:8090" \
-v /etc/sgx_default_qcnl.conf:/etc/sgx_default_qcnl.conf \
registry.gitlab.com/safeheron-mpc-node/smn/smn-ca:1.1.0 \
cacli status
-------------------- Output Example --------------------
CA Status: Authorized
Seal Type: Shamir
Total Shares: 3
Threshold: 2
Version: 1.1.0
Root Key Hash: 97271eb8****d150642c
MRENCLAVE: a9408284******23f5643
MRENCLAVE_SIG: business******de100
3、OP 确认 CA Server2 中 CA 配置文件中的AuthorizedCAUrl指向 CA Server1 的 IP 后,重启 CA 服务
# 部署第二台 CA 时需要配置,第一台不需要此配置
[Authority]
AuthorizedCAUrl = 'http://CA Server1's IP:8090'3、OP 在 CACLI-OP 终端执行以下命令,确认 CA Server2 启动完成并成功同步 rekey 信息,即命令输出的CA Status为 Authorized,且Root Key Hash与 CA Server1 输出的一致。其中 CA_ADDR 环境变量中的 IP 设置为 CA Server2 的主机 IP
$ docker run \
-it \
--rm \
--name mpcca-cli \
-e "CA_ADDR=http://CA Server2's IP:8090" \
-v /etc/sgx_default_qcnl.conf:/etc/sgx_default_qcnl.conf \
registry.gitlab.com/safeheron-mpc-node/smn/smn-ca:1.1.0 \
cacli status
-------------------- Output Example --------------------
CA Status: Authorized
Seal Type: Shamir
Total Shares: 3
Threshold: 2
Version: 1.1.0
Root Key Hash: 97271eb8****d150642c
MRENCLAVE: a9408284******23f5643
MRENCLAVE_SIG: business******de1004、集群 rekey 同步完成
OP 进行资源清理收尾工作
CACLI1、 CACLI2、CACLI3、CACLI-OP 主机中不保存任何数据,在以上所有操作执行完成后,即可释放主机资源。后续在需要时按需提供主机部署 CACLI 即可。