安装和升级 > 安装 ThingWorx > 安全配置 > TLS 配置 > 为 Akka 配置 SSL/TLS
为 Akka 配置 SSL/TLS
在本地环境中为 Akka 配置 SSL/TLS
* 
此分布式功能在 ThingWorx 9.4 及更高版本中可用。
要在本地环境中使用 ThingWorx HA 群集时为 Akka 配置 SSL,请执行以下步骤:
1. 创建将用于所有平台的 keystoretruststore
* 
关键字 secret 可替换为自定义密码。使用此密码访问创建的 keystore 和 truststore。
a. 要创建具有公钥和私钥的 keystore,请在终端执行以下命令:
keytool -v -genkeypair -dname "CN=SEEKERS,OU=RND,O=PTC,C=IL" -keystore akka-keystore.jks -storepass secret -keyalg RSA -keysize 2048 -alias server -validity 3650 -deststoretype pkcs12 -ext KeyUsage=digitalSignature,dataEncipherment,keyEncipherment,keyAgreement -ext ExtendedKeyUsage=serverAuth,clientAuth -ext SubjectAlternativeName:c=DNS:localhost,IP:127.0.0.1
b. 导出服务器证书。
keytool -v -exportcert -file server.cer -alias server -keystore akka-keystore.jks -storepass secret -rfc
c. 为客户端创建 truststore,并通过以下命令导入服务器证书:
keytool -v -importcert -file server.cer -alias server -keystore akka-truststore.jks -storepass secret -noprompt
2. 创建包含以下内容的 keystore.conf
{
security {
secret-provider = "com.thingworx.security.provider.keystore.KeyStoreProvider"
default-encryption-key-length = 128
keystore {
password-file-path = "I:\\ThingworxPlatform"
password-file-name = "keystore-password"
path = "I:\\ThingworxStorage"
name = "keystore"
}
}
}
* 
password-file-path 应为 ThingworxPlatform 文件夹的路径。path 应为 ThingworxStorage 文件夹的路径。
以下内容与 a、b 和 c 相关。将 keystoretruststore 密码添加到 ThingWorx 内部 keystore 以保护这些值。
a. 以下子步骤将使用内部 ThingWorx 工具 security-common-cli 将密码插入 keystore。security-common-cli 工具应存在于安装文件夹中。有关详细信息,请访问帮助中心内的安全管理工具。根据需要,使用不同版本的 keystore.conf 指定以下参数为每个平台重复此过程,:password-file-pathpath
b. 使用 security-common-cli 工具,在命令行中运行以下命令 (指定 security-common-tool 的有效路径)
:
cd [...]\security-common-cli-1.3.6.110\bin
security-common-cli
c. security-common-cli 终端中运行以下命令,并将 secret 替换为 truststorekeystore 的自定义密码。输入有效的 keystore.conf 路径。
> init [...]\keystore.conf
> set encrypt.akka.keystore.password "secret"
> set encrypt.akka.truststore.password "secret"
3. akka-keystore.jksakka-truststore.jks 文件放在已知路径下。路径可以是相对路径,也可以是绝对路径。例如,相对路径为 /ThingworxPlatform/[...]/akka-keystore.jks。绝对路径为 C:/akkaCerts/akka-keystore.jks
* 
只能有一个 akka-keystore.jksakka-truststore.jks 副本。由于为群集中的所有平台创建过一次这些文件,并将相同文件用于了所有平台,因此需为各个平台使用相同的副本。
* 
建议将这些文件放在 /ThingworxPlatform 文件夹下,并采用相对路径。
4. 按照 ThingWorx HA 的平台设置中所述,编辑 ThingworxPlatform\platform-settings.json 并在 AkkaSettings 部分下添加以下参数:AkkaSSLEnabledAkkaKeyStoreAkkaTrustStoreAkkaKeyStorePasswordAkkaTrustStorePasswordAkkaTlsProtocolVersion。提供有效的 akka-keystore.jksakka-truststore.jks 路径。
示例:
"AkkaSSLEnabled": true,
"AkkaKeyStore":"[...]/akka-keystore.jks",
"AkkaTrustStore":"[...]/akka-truststore.jks",
"AkkaKeyStorePassword":"encrypt.akka.keystore.password",
"AkkaTrustStorePassword":"encrypt.akka.truststore.password"
"AkkaTlsProtocolVersion":"TLSv1.2"
* 
AkkaTlsProtocolVersion 为可选参数。该参数的默认值为 TLSv1.2,后期可根据需要更改此值。
5. 重新启动应用程序。
这对您有帮助吗?