啟用 Liberty 應用程式用戶端儲存器的 SSL 通訊
Liberty 應用程式用戶端儲存器可能需要進行某種 SSL 配置,以便讓用戶端儲存器與伺服器通訊。為應用程式用戶端儲存器配置 SSL 時,需要使用伺服器啟用 SSL 時所需要的相同 SSL 特性 ssl-1.0。應用程式用戶端的配置元素和屬性,與伺服器相同;不過,對於應用程式用戶端儲存器,這些值是在 client.xml 檔中指定。
關於這項作業
SSL 信號交換是用戶端與伺服器之間,透過 SSL 通訊協定所交換的一系列訊息,用來進行連線特定的保護協議。如果要針對 Liberty 應用程式用戶端儲存器啟用 SSL,SSL 特性 ssl-1.0 必須包含構成用戶端使用之 SSL 配置所需的最基本資訊。要構成 SSL 配置,最基本要有的資訊是金鑰儲存庫和密碼。
您可以使用 securityUtility createSSLCertificate 指令,來建立用戶端的金鑰儲存庫,並提供配置資訊給您。工具是選用的,因為您也可以基於客戶所定義的其他用途,來建立金鑰儲存庫和相關聯的配置。
程序
<keyStore id="defaultKeyStore" password="yourPassword" />
這是建立 SSL 配置最基本需要的配置。在這項配置中,如果在 SSL 起始設定期間,金鑰儲存庫和憑證不存在,用戶端就會建立它們。所提供的密碼長度必須至少 6 個字元。JKS 是預設金鑰儲存庫類型,預設金鑰儲存庫稱為 key.jks,這些預設值位於 <client home>/resources/security 目錄中。
當使用先前的配置時,用戶端會在第一次啟動時建立 defaultKeyStore,不過,讓用戶端建立預設憑證,會有效能成本問題。為了避免效能成本問題,建議使用 securityUtilitiy createSSLCertificate 指令,來建立 defaultKeyStore 配置中所用的預設金鑰儲存庫。
如果您需要自訂 SSL 配置,請參閱 Liberty:SSL 配置屬性。
- 接受簽章者憑證
- 如果用戶端未與伺服器之間建立信任關係,與用戶端通訊時,會提示使用者,並詢問他們是否接受來自伺服器的憑證。如果使用者的回應是 yes,就會擷取憑證並儲存在用戶端金鑰儲存庫配置中,且指令繼續進行。如果使用者指定 no,就不會建立信任,且呼叫因錯誤而結束。提示範例類似如下:
*** 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)
當詢問使用者是否新增簽章者至信任儲存庫時,如果使用者指定 no,您可能收到下列錯誤訊息:[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,從應用程式用戶端儲存器的金鑰儲存庫中擷取簽章者,並將用戶端中的憑證新增至伺服器的信任儲存庫中。