DZone
Thanks for visiting DZone today,
Edit Profile
  • Manage Email Subscriptions
  • How to Post to DZone
  • Article Submission Guidelines
Sign Out View Profile
  • Post an Article
  • Manage My Drafts
Over 2 million developers have joined DZone.
Log In / Join
Refcards Trend Reports
Events Video Library
Refcards
Trend Reports

Events

View Events Video Library

Related

  • Implement a Distributed Database to Your Java Application
  • How to Secure Apache Ignite From Scratch
  • AI Agents in Java: Architecting Intelligent Health Data Systems
  • Building an Image Classification Pipeline With Apache Camel and Deep Java Library (DJL)

Trending

  • RAG Done Right: When to Use SQL, Search, and Vector Retrieval and How To Combine Them
  • Dear Micromanager: Your Distrust Has a Job; It’s Just Not the One You’re Doing
  • Bridging Gaps in SOC Maturity Using Detection Engineering and Automation
  • The Cost of Knowing: When Observability Becomes the Outage
  1. DZone
  2. Software Design and Architecture
  3. Security
  4. Differences between Keystore and Truststore

Differences between Keystore and Truststore

Finally master pesky Keystore and Truststore.

By 
Crumb Peter user avatar
Crumb Peter
·
Oct. 01, 19 · Presentation
Likes (6)
Comment
Save
Tweet
Share
61.8K Views

Join the DZone community and get the full member experience.

Join For Free

metal-keys-on-a-ring


Keystore and Truststore are both important and essential for communication with an SSL Certificate. Both are very similar in terms of construct and structure, as both are managed by a key tool command.

Truststore is used for the storage of certificates from the trusted Certificate Authority (CA), which is used in the verification of the certificate provided by the server in an SSL connection. On the other hand, a Keystore is used to store the private key and own identity certificate to be identified for verification.

You may also like: How to Generate a Keystore and CSR Using the Keytool Command.

In an SSL handshake, the work of Truststore is to verify the credentials, whereas the work of Keystore is to provide those credentials. These are the most important differences between Truststore and Keystore but not the only ones. These differences vary in Java and they are as follows –

  • Truststore is used by Trust Manager and Keystore is used by Key Manager; they both perform different functions.

  • Keystore contains private keys and is required only when a server is running on an SSL connection, whereas Truststore store public keys and the certificates issued form the certificate authority.

  • To specify the path of a Keystore or Truststore, we need different extensions in Java. (Djavax.net.ssl.keyStore for Keystore and -Djavax.net.ssl.trustStore for Truststore.)

  • There is also a difference in the password of the two (i.e. for Keystore it is given by the following extension Djavax.net.ssl.keyStorePassword and for truststore is given by Djavax.net.ssl.trustStorePassword).

  • Keystore contains one private key for the host, while truststore contains zero private keys.

The listing, removal, and addition of certificates can be done from the Java Keystore by using the keytool utility. Almost all of the SSL clients have access to the Truststore.

Security Considerations for Keystore and Truststore 

Keystores contain private keys, whereas Truststore do not. Security for Keystores is strict and exacting. In particular –

  • Hadoop SSL (Secure Sockets Layer) has a requirement that Truststores and the Truststore password have to be stored in plaintext, in a configuration file that can be read easily by everyone.
  • Keystore and key passwords are stored in plaintext, in a file that is readable only by members of the appropriate group.
  • Since Truststore does not contain any private and sensitive information, only a single Truststore for an entire cluster is sufficient.
  • But it is essential information that the passwords for both Truststore and Keystore should not be the same because the password for Truststore is stored in clear files and is visible to all. If the same password is used for a Keystore, the security will be vulnerable and can be attacked by malicious parties and hackers.

Creating Trusutstores 

If one is using the default Truststore, he/she needs to add Certificate Authority (CA) to the Truststore or delete them from Truststore. If you are creating a custom Truststore, you must build the Truststore by importing trusted certificates into new Truststores. While creating a Truststore, a password has to be created/selected, and they should be the same for a given service.

The purpose of a Keystore is to protect privacy and integrity with the use of a password-based algorithm. The keys are kept secret to keep them safe and protected from unwanted third parties and can only be accessed by someone having the password.


Related Articles

  • Securing REST APIs With Client Certificates.
Certificate authority security Java (programming language) Connection (dance) Command (computing) cluster Host (Unix) AI Web Protocols

Published at DZone with permission of Crumb Peter. See the original article here.

Opinions expressed by DZone contributors are their own.

Related

  • Implement a Distributed Database to Your Java Application
  • How to Secure Apache Ignite From Scratch
  • AI Agents in Java: Architecting Intelligent Health Data Systems
  • Building an Image Classification Pipeline With Apache Camel and Deep Java Library (DJL)

Partner Resources

×

Comments

The likes didn't load as expected. Please refresh the page and try again.

  • RSS
  • X
  • Facebook

ABOUT US

  • About DZone
  • Support and feedback
  • Community research

ADVERTISE

  • Advertise with DZone

CONTRIBUTE ON DZONE

  • Article Submission Guidelines
  • Become a Contributor
  • Core Program
  • Visit the Writers' Zone

LEGAL

  • Terms of Service
  • Privacy Policy

CONTACT US

  • 3343 Perimeter Hill Drive
  • Suite 215
  • Nashville, TN 37211
  • [email protected]

Let's be friends:

  • RSS
  • X
  • Facebook