6.4. 使用对称加密保护集群传输
配置 Data Grid 集群,以使用您提供的密钥存储的机密密钥加密 JGroups 消息。
流程
- 创建包含机密密钥的密钥存储。
将密钥存储放在集群中的每个节点的类路径上。
对于 Data Grid Server,您可以将密钥存储放在 $RHDG_HOME 目录中。
-
将
SYM_ENCRYPT协议添加到数据网格配置中的 JGroups 堆栈。
<infinispan>
<jgroups>
<!-- Creates a secure JGroups stack named "encrypt-tcp" that extends the default TCP stack. -->
<stack name="encrypt-tcp" extends="tcp">
<!-- Adds a keystore from which nodes obtain secret keys. -->
<!-- Uses the stack.combine and stack.position attributes to insert SYM_ENCRYPT into the default TCP stack after VERIFY_SUSPECT. -->
<SYM_ENCRYPT keystore_name="myKeystore.p12"
keystore_type="PKCS12"
store_password="changeit"
key_password="changeit"
alias="myKey"
stack.combine="INSERT_AFTER"
stack.position="VERIFY_SUSPECT"/>
</stack>
</jgroups>
<cache-container name="default" statistics="true">
<!-- Configures the cluster to use the JGroups stack. -->
<transport cluster="${infinispan.cluster.name}"
stack="encrypt-tcp"
node-name="${infinispan.node.name:}"/>
</cache-container>
</infinispan>
验证
当您启动 Data Grid 集群时,以下日志消息表示集群使用 secure JGroups 堆栈:
[org.infinispan.CLUSTER] ISPN000078: Starting JGroups channel cluster with stack <encrypted_stack_name>
只有使用 SYM_ENCRYPT 并且可以从共享密钥存储获取 secret 密钥时,才可以加入集群。否则,以下消息被写入 Data Grid 日志:
[org.jgroups.protocols.SYM_ENCRYPT] <hostname>: received message without encrypt header from <hostname>; dropping it