为 Windchill 双向 SSL 连接设置 ThingWorx 和 ThingWorx Flow (仅适用于 9.0)
|
此主题不适用于 ThingWorx Flow 9.0.2 及更高版本。
|
PTC 建议使用适用于生产环境的安全套接字层 (SSL) 协议。ThingWorx 使用 SSL 对服务器进行相互身份验证,并保护服务器之间的通信。
HTTPS 配置要求使用颁发机构的证书。ThingWorx 要求证书受 Java 信任。如果要使用的证书不受 Java 信任,则必须将 Java 配置为信任此证书。由第三方厂商提供的证书 (如 Verisign 和 Thawte) 是受 Java 信任的颁发机构证书。
|
本文档提供了针对安装执行 HTTPS 所需的最少步骤。而并未详尽列出 SSL 配置中的所有可用选项。
|
先决条件
在为 Windchill 双向 SSL 连接设置 ThingWorx 和 ThingWorx Flow 前,请确保满足以下先决条件:
• 已使用以下证书配置 Windchill (仅当 Windchill 证书为自签名证书时才需如此):
◦ Windchill 证书
本文档假定 Windchill 证书存储在 server.crt 文件中。
◦ 用于创建 Windchill 证书的 CA 证书。
本文档假定 CA 证书存储在 rootCA.crt 文件中。
• 请确保将 JAVA_HOME/bin 添加至 PATH 环境变量。
步骤
以下是该过程的主要步骤:
|
如果已为 ThingWorx Navigate 的相同 ThingWorx 实例设置了 SSL,请跳过此步骤。
|
步骤 1:针对 Windchill 双向 SSL 连接配置 ThingWorx
要针对 Windchill 双向 SSL 连接配置 ThingWorx,您必须生成一个 KeyStore 文件,以使用自签名证书接受 SSL 连接。为此,请执行以下步骤:
1. 以管理员身份启动命令提示符,然后浏览至要保存 KeyStore 文件的位置。
2. 创建 Java KeyStore (JKS) 文件 thingworx.jks,然后使用别名 thingworx 生成初始公钥和私钥对:
keytool -genkey -alias thingworx -keyalg rsa -dname "CN=<Fully Qualified Domain Name of the ThingWorx Server>" -keystore thingworx.jks -storetype JKS
当出现提示时,为 KeyStore 文件和私钥输入相同的密码。
请确保密码仅含字母和数字。不支持特殊字符。PTC 对证书和所生成密钥库和信任库文件的安全性不承担任何责任。
|
如果不以管理员身份启动命令提示符,则可能会收到以下错误:
keytool error: java.io.FileNotFoundException: thingworx.jks (Access is denied)
|
3. 生成密钥的自签名证书:
keytool -selfcert -alias thingworx -validity 1825 -keystore thingworx.jks -storetype JKS
当系统提示输入 KeyStore 密码时,请输入与之面命令相同的密码。
4. 导出新自签名证书的公钥:
keytool -export -alias thingworx -file thingworx.cer -rfc -keystore thingworx.jks -storetype JKS
步骤 2:针对 Windchill 双向 SSL 连接配置 ThingWorx Flow
A 部分 - 获取与 thingworx.jks KeyStore 相关联的证书和私钥
2. 在 KeyStore Explorer 中,打开 thingworx.jks,即之前在步骤 1 中创建的 ThingWorx KeyStore。
在出现提示时,输入 KeyStore 的正确密码。
3. 右键单击 thingworx,然后单击 > ,以导出与 thingworx.jks KeyStore 相关联的证书:
4. 在条目 "thingworx" 窗口的“导出证书链”中,执行以下操作:
a. 对于“导出长度”,选择“仅请求头”。
b. 对于“导出格式”,选择 X.509。
c. 选中 PEM 复选框。
d. 在“导出文件”字段中,单击“浏览”以浏览至要保存所导出证书的位置。例如:thingworx.crt。
e. 单击“导出”。
5. 右键单击 thingworx,然后单击 > ,以导出与 thingworx.jks KeyStore 相关联的私钥。
6. 在“导出私钥类型”窗口中,选择 PKCS#8,然后单击“确定”。
7. 在 KeyStore 条目 "thingworx" 窗口的“导出私钥作为 PKCS#8”中,执行以下操作:
a. 清除“加密”复选框。
b. 选中 PEM 复选框。
c. 在“导出文件”字段中,单击“浏览”以浏览至要保存所导出私钥的位置。例如:thingworx.key。
d. 单击“导出”。
B 部分 - 将 ThingWorx 和 Windchill 证书添加至 ThingWorx Flow 信任库
1. secret 参数的值可用于解密信任库。要获取 secret 参数的值,请以管理员身份在安装 ThingWorx Flow 的计算机上启动命令提示符,然后运行以下命令:
a. pm2 ls
请记下任何 ThingWorx Flow 服务的 ID 值。
b. pm2 env <ID>
,其中 <ID> 为任何 ThingWorx Flow 服务的 ID。例如:flow-api 服务的 ID。
c. 复制 CONFIG_IMAGE 变量的值。此为 secret 参数的值。
2. 运行以下命令:
<ThingWorx Flow Installation Directory>\cryptography\tw-security-common-nodejs npm link
3. 运行以下命令将 thingworx.crt 证书文件添加至信任库:
PtcOrchKeyFileTool set --keyName thingworx-crt --keyPath <Path to thingworx.crt> --configPath <<Absolute path to the config.json file of any Flow Service> --secret <Secret to decrypt the TrustStore>
请勿更改 keyName 参数的值。必须将其设置为 thingworx-crt。
4. 运行以下命令将 thingworx.key 私钥文件添加至信任库:
PtcOrchKeyFileTool set --keyName thingworx-key --keyPath <thingworx.key 的路径> --configPath <任意 Flow 服务的 config.json 文件的绝对路径> --secret <解密 TrustStore 的密钥>
请勿更改 keyName 参数的值。必须将其设置为 thingworx-key。
5. 如果 Windchill 证书为自签名证书,则请执行以下操作:
a. 新建文件 ca.crt。
b. 将 rootCA.crt 和 server.crt 文件的内容复制到 ca.crt 文件中。
c. 运行以下命令将 Windchill 证书添加至信任库:
PtcOrchKeyFileTool set --keyName <Windchill-crt>--keyPath <ca.crt 文件的路径> --configPath <任意 Flow 服务的 config.json 文件的绝对路径> --secret <解密 TrustStore 的密钥>
对于此命令,可更改 keyName 参数的值。对于多个 Windchill 服务器,请确保为 keyName 参数设置不同的值。
6. 重新启动 ThingWorx 和 ThingWorx Flow 服务器。
您已成功为 Windchill 双向 SSL 连接设置了 ThingWorx 和 ThingWorx Flow。
现在,可以为任何 Windchill 操作添加 Windchill 双向 SSL 连接。有关详细信息,请参阅
添加 Windchill 双向 SSL 连接。