Truststore and keystore: what are they and why do I care?
The SSL protocol is based on public-key cryptography where encryption keys come in pairs that are mathematically related, but one cannot be deduced from knowing the other. the pair consists of the private key and the Public Key (private, public ). the private key remains under the protection of the entity to which it belongs. note that the owner really owns the pair, but the public key, as its name suggests, can be publicly known, or at least is freely disseminated to the entities that communicate with the owner of the public/private key pair. the security services that public key cryptography enable are based on the fact that a message encrypted using the public key can only be decrypted by the corresponding private key, and vice versa. thus, if one encrypts a message using the public key of an entity, then it is guaranteed that only the entity can decrypt the message. an immediate question that comes to mind is how to be assured that the public key being used is indeed bound to a legitimate entity and not to someone else. that is where public key infrastructures (PKI) comes into play (see resources ).
Figure 1. The relationship between client and server truststore/keystore
Public Keys are distributed in containers called Public Key Certificates (PKCS ). these are data constructs digitally signed by some signer (typically a certificate authority, but public keys can be self-signed ). A digital signature stamps a proof of origin authenticity. one point to remember is that trust in computer security must be computationally verifiable. in order to verify that a public key certificate is legitimate, I need to verify the signature of the signer that issued it. this process is, in turn, based on the public key of the signer.
This is where the truststore comes into play. when using JSSE for SSL communication, one needs to maintain the set of trusted signer certificates in a local store, hence the name truststore. the truststore on the client side, for example, is used by the JSSE runtime in order to verify that a client attempting to connect to a server is indeed interacting with a server with a legitimate certificate (one that is issued by a trusted signer ). therefore, the signer of the server certificate must have a pkstored in the truststore of the client. figure 1 into strates the relationship between client and server truststore/keystore.
By the same token, the server must have its private key locally protected and make it accessible to the JSSE runtime. that's where the keystore comes into play. A keystore has the same format as a truststore, it just contains different keys. in fact, the generic term "keystore" is typically used to mean "truststore or keystore."
In summary, truststores contain certificates for the signers that are trusted in the environment where the truststore is used. A keystore, on the other hand, maintains the private key of an entity, as well as its corresponding PKC. for example, when a server authenticates itself to the client, it needs to retrieve its private key from its keystore in order to engage in an SSL handshake with the client. so, one shoshould really care about what signers to trust; that is, the content of the truststore being used. the IBM-provided default truststore provided des several well known and widely trusted Certificate authorites (CA ). one good practice here is to periodically browse through your truststore and make your own judgment about the trustworthiness of its content -- and possibly remove some CAS.
Now that we know what a truststore is and what a keystore is, let's look at how they are defined in the WebSphere Application Server environment using the ibm jsse.
Http://hi.baidu.com/liansm%5Ftech/blog/item/77d600fbd2cd1d60034f569a.html