对 Liberty 应用程序客户机容器启用 SSL 通信
Liberty 应用程序客户机容器可能需要一些 SSL 配置以供客户机容器与服务器通信。为应用程序客户机容器配置 SSL 需要使用相同的 SSL 功能部件 ssl-1.0,服务器在启用 SSL 时需要同一功能。对于应用程序客户机和服务器,配置元素和属性是相同的;但是,对于应用程序客户机容器,这些值是在 client.xml 文件中指定的。
关于此任务
SSL 握手是一系列消息,系统在客户机与服务器之间通过 SSL 协议交换这些消息以进行协商,从而实现特定于连接的保护。要对 Liberty 应用程序客户机容器启用 SSL,SSL 功能部件 ssl-1.0 必须包含生成客户机使用的 SSL 配置时所需的基本信息。构成 SSL 配置时所需的基本信息是密钥库和密码。
可使用 securityUtility createSSLCertificatecommand 以创建客户机密钥库并为您提供有关该配置的信息。可选择使用工具,因为您也可创建密钥库及关联配置以实现其他客户定义用途。
过程
<keyStore id="defaultKeyStore" password="yourPassword" />
这是创建 SSL 配置时所需的最低配置。在此配置中,如果 SSL 初始化期间密钥库和证书不存在,那么客户机会创建密钥库和证书。提供的密码长度必须至少为 6 个字符。JKS 是缺省密钥库类型,缺省密钥库称为 key.jks,这些缺省值位于 <client home>/resources/security 目录。
使用先前配置时,客户机将在首次启动时创建 defaultKeyStore,但让客户机创建缺省证书会降低性能。为避免降低性能,建议使用 securityUtilitiy createSSLCertificate 命令创建 defaultKeyStore 配置中使用的缺省密钥库。
如果需要定制 SSL 配置,请参阅 Liberty 概要文件:SSL 配置属性。
- 接受签署者证书
- 如果客户机没有与服务器建立信任关系,那么与客户机的通信会提示用户并询问他们是否接受来自服务器的证书。如果用户回答是,那么证书被接受并存储在客户机密钥库配置中,命令继续执行。如果用户指定否,那么不会建立信任关系,调用结束并产生错误。有关提示外观的示例:
*** SSL SIGNER EXCHANGE PROMPT *** The SSL signer from target host is not found in trust store C:/liberty/workspace/build.image/wlp/usr/clients/myTestClient/resources/security/key.jks. Here is the signer information (verify the digest value matches what is displayed at the server): Subject DN: CN=localhost, O=ibm, C=us Issuer DN: CN=localhost, O=ibm, C=us Serial number: 1327582458 Expires: Sun Jan 04 06:54:18 CST 2099 SHA-1 Digest: 00:6F:25:F1:78:5D:EB:00:B1:E2:99:DB:E8:D7:DF:3B:F8:E0:20:9A Add signer to the trust store now? (y/n)
如果用户在被要求将签署者添加至信任库时指定否,那么可能会出现以下错误信息:[ERROR ] CWPKI0022E: SSL HANDSHAKE FAILURE: A signer with SubjectDN CN=localhost, O=ibm, C=us sent from the target host. The signer might need to be added to local trust store C:/liberty/workspace/build.image/wlp/usr/clients/myTestClient/resources/security/key.jks, located in SSL configuration alias defaultSSLConfig. The extended error message from the SSL handshake exception is: PKIX path building failed: java.security.cert.CertPathBuilderException: PKIXCertPathBuilderImpl could not build a valid CertPath.; internal cause is: java.security.cert.CertPathValidatorException: The certificate issued by SubjectDN CN=localhost, O=ibm, C=us is not trusted; internal cause is: java.security.cert.CertPathValidatorException: Certificate chaining error throw able: javax.net.ssl.SSLHandshakeException: java.security.cert.CertificateException: PKIX path building failed: java.security.cert.CertPathBuilderException : PKIXCertPathBuilderImpl could not build a valid CertPath.; internal cause is: java.security.cert.CertPathValidatorException: The certificate issued by SubjectDN CN=localhost, O=ibm, C=us is not trusted; internal cause is: java.security.cert.CertPathValidatorException: Certificate chaining error
- 自动接受签署者证书
- 如果客户机不希望收到要求提供签署者证书的提示,并选择接受服务器签署者证书而不检查该证书,那么该用户可在客户机容器命令行中添加 -autoAcceptSigner 标记。
client run client_name --autoAcceptSigner
- 客户机认证
- 如果客户机要与已启用客户机认证的服务器通信,那么服务器与客户机需要相互信任。客户机的密钥库中必须具有密钥和个人证书。如果使用 securityUtility createSSLCertificate 命令,那么密钥库包含个人证书。要与客户机应用程序容器通信的服务器必须信任客户机,所以需要将客户机中的签署者添加至服务器的信任库。可使用 Java 工具 keytool 从应用程序客户机容器的密钥库中抽取签署者,并将客户机中的证书添加至服务器的信任库。