2.2. 使用 Asymmetric Encryption 配置集群传输
配置 Data Grid 集群,以生成和分发加密 JGroups 消息的 secret 密钥。
流程
- 使用证书链创建密钥存储,使 Data Grid 能够验证节点身份。
将密钥存储放在集群中每个节点的 classpath 上。
对于 Data Grid Server,您要将密钥存储放在 $RHDG_HOME 目录中。
将
SSL_KEY_EXCHANGE和ASYM_ENCRYPT协议添加到 Data Grid 配置中的 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 that nodes use to perform certificate authentication. --> <!-- Uses the stack.combine and stack.position attributes to insert SSL_KEY_EXCHANGE into the default TCP stack after VERIFY_SUSPECT. --> <SSL_KEY_EXCHANGE keystore_name="mykeystore.jks" keystore_password="changeit" stack.combine="INSERT_AFTER" stack.position="VERIFY_SUSPECT"/> <!-- Configures ASYM_ENCRYPT --> <!-- Uses the stack.combine and stack.position attributes to insert ASYM_ENCRYPT into the default TCP stack before pbcast.NAKACK2. --> <!-- The use_external_key_exchange = "true" attribute configures nodes to use the `SSL_KEY_EXCHANGE` protocol for certificate authentication. --> <ASYM_ENCRYPT asym_keylength="2048" asym_algorithm="RSA" change_key_on_coord_leave = "false" change_key_on_leave = "false" use_external_key_exchange = "true" stack.combine="INSERT_BEFORE" stack.position="pbcast.NAKACK2"/> </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>
只有在它们使用 ASYM_ENCRYPT 且可以从协调器节点获取 secret 密钥时,数据网格节点才能加入集群。否则,以下信息会写入 Data Grid 日志:
[org.jgroups.protocols.ASYM_ENCRYPT] <hostname>: received message without encrypt header from <hostname>; dropping it
参考
此流程中的 ASYM_ENCRYPT 配置示例显示了常用的参数。如需完整的可用参数集合,请参阅 JGroups 文档。