3.4. 配置 Hot Rod 客户端加密
Data Grid Server 可以强制 SSL/TLS 加密,并呈现带有证书的 Hot Rod 客户端,以建立信任并协商安全连接。
要验证向 Data Grid Server 发布的证书,Hot Rod 客户端需要完整的证书链或以 Root CA 开头的部分链。您可以将服务器证书提供给 Hot Rod 客户端作为信任存储。
默认情况下,Hot Rod 客户端还将通过匹配 dNSName 或 iPAddress 或服务器证书的 subjectAltName 扩展中包含的两个类型来执行主机名验证。
提示
另外,您还可以提供信任存储,您可以使用共享系统证书。
先决条件
- 创建 Hot Rod 客户端可用于验证数据网格服务器身份的信任存储。
- 如果您将 Data Grid Server 配置为验证或验证客户端证书,请根据情况创建密钥存储。
流程
-
使用
trustStoreFileName ()和trustStorePassword ()方法或对应属性将信任存储添加到客户端配置中。 如果配置客户端证书身份验证,请执行以下操作:
-
使用
keyStoreFileName ()和keyStorePassword ()方法或对应属性,将密钥存储添加到客户端配置中。 -
将客户端配置为使用
EXTERNAL身份验证机制。
-
使用
ConfigurationBuilder
ConfigurationBuilder clientBuilder = new ConfigurationBuilder();
clientBuilder
.addServer()
.host("127.0.0.1")
.port(11222)
.security()
.ssl()
// Server SNI hostname.
.sniHostName("myservername")
// Keystore that contains the public keys for Data Grid Server.
// Clients use the trust store to verify Data Grid Server identities.
.trustStoreFileName("/path/to/server/truststore")
.trustStorePassword("truststorepassword".toCharArray())
.trustStoreType("PCKS12")
// Keystore that contains client certificates.
// Clients present these certificates to Data Grid Server.
.keyStoreFileName("/path/to/client/keystore")
.keyStorePassword("keystorepassword".toCharArray())
.keyStoreType("PCKS12")
.authentication()
// Clients must use the EXTERNAL mechanism for certificate authentication.
.saslMechanism("EXTERNAL");
hotrod-client.properties
infinispan.client.hotrod.server_list = 127.0.0.1:11222
infinispan.client.hotrod.use_ssl = true
# Use SNI for hostname validation
infinispan.client.hotrod.sni_host_name = myservername
# Keystore that contains the public keys for Data Grid Server.
# Clients use the trust store to verify Data Grid Server identities.
infinispan.client.hotrod.trust_store_file_name = server_truststore.pkcs12
infinispan.client.hotrod.trust_store_password = changeme
infinispan.client.hotrod.trust_store_type = PCKS12
# Keystore that contains client certificates.
# Clients present these certificates to Data Grid Server.
infinispan.client.hotrod.key_store_file_name = client_keystore.pkcs12
infinispan.client.hotrod.key_store_password = changeme
infinispan.client.hotrod.key_store_type = PCKS12
# Clients must use the EXTERNAL mechanism for certificate authentication.
infinispan.client.hotrod.sasl_mechanism = EXTERNAL
后续步骤
将客户端信任存储添加到 $RHDG_HOME/server/conf 目录,并将 Data Grid Server 配置为使用它(如果需要)。