使用 SSL 进行安全通信的配置示例
  
使用 SSL 进行安全通信的配置示例
以下示例介绍了针对受信任的 SSL 通信配置 WindchillThingWorx 的一种方法。本示例使用自签署证书在 WindchillThingWorx 之间提供安全通信,这适用于在企业防火墙内进行通信的环境。在这种情况下会产生 Internet 流量,因此建议采用商业信任证书。
* 
下述说明依赖于 PTC HTTP 服务器的最新版本随附的配置脚本。Windchill 11.0 M020 和 Windchill 10.2 的最新 CPS 版本都包含最新的 PTC HTTP 服务器。
本示例假定 Windchill 已配置为使用 SSL。
本主题适用于旧款 Windchill 连接器 WindchillConnector,该连接器用于 PTC Navigate 1.4 及更早版本。
旧款 Windchill 连接器也可以用于 ThingWorx 单一登录环境。
此处使用的密钥不必与 WindchillThingWorx Web 界面所使用的密钥相同。
代码示例已重新格式化以便适应页面大小,因此可能包含行号、隐藏的编辑字符 (例如制表符和行尾字符) 和额外的空格。在剪切并粘贴代码时,请检查上述字符并将其移除,之后再尝试在您的应用程序中使用此示例。
1. ThingWorx 创建信任存储区并导入 Windchill 证书:
2. ThingWorx 创建密钥存储区。
3. Windchill 配置为信任 ThingWorx
* 
如果 ThingWorxWindchill 位于不同的系统上,则可在 Windchill 服务器上执行步骤 3 的 a、b 和 c。然后,将 *.jks 文件复制到 ThingWorx 服务器。
a. 更新 PTC HTTP 服务器配置,以参考 CA 证书文件。
a. 导航至 <HTTPSERVER_HOME>/conf/extra/httpd-ssl.conf 并进行编辑。
b. 取消注释 SSLCACertificateFile 条目,使其参考 ca-bundle.crt 文件。请记下 ca-bundle.crt 文件的位置。
c. 保存更改。
b. ThingWorx 证书添加到 PTC HTTP 服务器的受信任 CA 证书列表。
a. 编辑您之前在 SSLCACertificateFile 条目中所指向的 ca-bundle.crt 文件。
* 
如果文件尚不存在,请创建文件和任何所需的目录。
b. 将保存在信任存储区中的 ThingWorx 证书 (上述步骤 2 a 中的 servercert.pem) 的内容附加至此文件。
c. 保存更改。
c. 配置 PTC HTTP 服务器,使其将证书信息导出到 Windchill
a. 编辑 <HTTPSERVER_HOME>/conf/extra/httpd-ssl.conf
b. 查找含有 SSLOptions 的行。
c. 取消注释含有 SSLOptions +ExportCertData 的行。
例如:
SSLOptions +FakeBasicAuth +ExportCertData +StrictRequire<FilesMatch "\.(cgi|shtml|phtml|php)$"> SSLOptions +StdEnvVars/FilesMatch><Directory "C:/ptc/Windchill_10.2/HTTPServer/cgi-bin"> SSLOptions +StdEnvVars</Directory>
d. 保存更改。
d. 针对 sslClientAuth URL 配置 PTC HTTP 服务器。
a. <windchill-home>/codebase/wt.propertieswt.webapp.name 条目中查找 Windchill Web 应用程序名称。
b. 打开 shell 或命令提示符,然后输入以下内容:
cd <HTTPSERVER_HOME>ant -f webAppConfig.xml -DappName=[windchill-web-app]
-Dresource=sslClientAuth -DresourceAuthType=sslClientAuth addAuthResource
c. Windchill 配置为信任 ThingWorx 证书。
a. 编辑 <windchill-home>/codebase/WEB-INF/web.xml
b. 查找 <filter-name>TrustedSSLAuthFilter</filtername>
c. 在现有的 <init-param> 元素后添加另一个这样的元素,其中 [thingworx-cert-name]ThingWorx 证书的名称。对于自签署证书,证书名称为运行 keytool -list -v -keystore <path-to-ThingWorxKeyStore.jks> 时证书的所有者值:
<init-param><param-name>trustedSubjectPattern.1 </param-name><param-value>[thingworx-cert-name]</param-value>
</init-param>
d. 保存更改。
4. 针对 SSL 配置 ThingWorx
a. ThingWorx Composer 中,编辑 ptc-windchill-demo-thing 事物模板,该模板表示与所配置的 Windchill 系统的连接。
b. 指定 ThingWorxKeyStore.jks 的路径 (请参见屏幕截图中的示例),并指定密码。
c. 指定 ThingWorxTrustStore.jks 的路径 (请参见屏幕截图中的示例),并指定密码。
d. 指定 Windchillhttps 地址和 SSL 端口。
e. 保存事物。
f. 查看 ThingWorx 应用程序日志,以验证不存在任何配置错误。
5. 启动 ptc-connected-demo-mashup 以验证 ThingWorx - Windchill 信任的 SSL 配置。
* 
要配置新款 Windchill 连接器,请参阅配置 ThingWorx Navigate 使用 Windchill 身份验证