當前位置: 首頁>>編程示例 >>用法及示例精選 >>正文


Java trustStore和keyStore的區別用法及代碼示例

TrustStore 用於存儲來自認證機構 (CA) 的證書,該機構驗證 SSL 連接中服務器提供的證書。而Keystore用於存儲私鑰和身份證書,特定程序應將其呈現給雙方(服務器或客戶端)進行驗證。由此得出的結論是,它們是相反的。通俗地說,我們可以直接得出這樣的結論:在認證中,trustStore 保存的是識別他人的身份證書,而 keyStore 保存的是識別我們的身份證書。

在 Java 中和在編程語言中一樣,每當我們嘗試與第三方應用程序通信時都會使用這個概念。客戶端和服務器之間的連接用keyStore和trustStore來圖示,如下:

TrustStore和KeyStore之間的區別如下表內容所示:

TrustStore

KeyStore

TrustStore不包含私人和敏感信息。

Keystore contains private and sensitive information.

javax.net.ssl.trustStore is used to specify TrustStore.

javax.net.ssl.keyStore is used to specify Keystore.

TrustStore setup is required for the successful connection at the client side.

在 SSL 上設置服務器端時需要 key 庫。

TrustStore 存儲其他人的憑據。

Keystore stores your credential.

A TrustStore holds the certificates of external systems that you trust.

KeyStore 保存您的應用程序的證書。

TrustStore password is given by following extension Djavax.net.ssl.trustStorePassword.

KeyStore password is given by following extension Djavax.net.ssl.keyStorePassword

TrustStore and TrustStore passwords are stored in clear files and is visible to all.

Keystore and key passwords are stored in plain text, in a file that is readable only by members of the appropriate group.


相關用法


注:本文由純淨天空篩選整理自pranaythanneru大神的英文原創作品 Difference Between trustStore and keyStore in Java。非經特殊聲明,原始代碼版權歸原作者所有,本譯文未經允許或授權,請勿轉載或複製。