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
Please enter at least three characters to search
Refcards Trend Reports
Events Video Library
Refcards
Trend Reports

Events

View Events Video Library

Zones

Culture and Methodologies Agile Career Development Methodologies Team Management
Data Engineering AI/ML Big Data Data Databases IoT
Software Design and Architecture Cloud Architecture Containers Integration Microservices Performance Security
Coding Frameworks Java JavaScript Languages Tools
Testing, Deployment, and Maintenance Deployment DevOps and CI/CD Maintenance Monitoring and Observability Testing, Tools, and Frameworks
Culture and Methodologies
Agile Career Development Methodologies Team Management
Data Engineering
AI/ML Big Data Data Databases IoT
Software Design and Architecture
Cloud Architecture Containers Integration Microservices Performance Security
Coding
Frameworks Java JavaScript Languages Tools
Testing, Deployment, and Maintenance
Deployment DevOps and CI/CD Maintenance Monitoring and Observability Testing, Tools, and Frameworks

The software you build is only as secure as the code that powers it. Learn how malicious code creeps into your software supply chain.

Apache Cassandra combines the benefits of major NoSQL databases to support data management needs not covered by traditional RDBMS vendors.

Generative AI has transformed nearly every industry. How can you leverage GenAI to improve your productivity and efficiency?

Modernize your data layer. Learn how to design cloud-native database architectures to meet the evolving demands of AI and GenAI workloads.

Related

  • How to Modify Java Command-Line Arguments
  • JGit Library Examples in Java
  • Quickly Find Your Java Application Process ID
  • How to Kill Processes in Unix/Linux

Trending

  • Tired of Spring Overhead? Try Dropwizard for Your Next Java Microservice
  • The Smart Way to Talk to Your Database: Why Hybrid API + NL2SQL Wins
  • Chat With Your Knowledge Base: A Hands-On Java and LangChain4j Guide
  • MCP Servers: The Technical Debt That Is Coming
  1. DZone
  2. Coding
  3. Java
  4. The Most Common Java Keytool Keystore Commands

The Most Common Java Keytool Keystore Commands

A full list of the most commonly used keystore creating, importing, and checking commands for the Java Keytool platform.

By 
Crumb Peter user avatar
Crumb Peter
·
Dec. 07, 20 · Tutorial
Likes (7)
Comment
Save
Tweet
Share
14.5K Views

Join the DZone community and get the full member experience.

Join For Free

Java Keytool Keystore Commands

The platform that manages the private keys and certificates is called Java Keytool. It has the ability through which public/private keys and certificate manage in addition to caching certificates. The storing place of keys and certificates is named by Java as Keystore. Java Keystore represents a file. The private keys are protected with a password in Keystore. The chain of trust and primary certificate trustworthiness is established by Keytool Keystore that is necessary to protect the private keys and certificates.

 

A unique alias is associated with each certificate in Java Keystore. First, you have to create a .jks file that will initially consist of only private keys. After that, CSR needs to be generated from which certificate will be generated. Then the certificate should be imported into the Keystore including root certificates. There are various functions that are performed by the Java Keytool like viewing of certificate details or a list of certificates consist of export a certificate.

 

What is Java Keytool Keystore

This is a platform that stores the private keys and certificates, which is important for the chain of trust and primary certificate authentication. This creation of a domain takes the place of a primary certificate.

 

Java Keytool Commands for Creating and Importing

Let’s start with the most basic and generate commands on how to import keys and certificates.

Java Keystore and Keypair Generation

keytool –genkey –alias mydomain –keyalg RSA –keystorekeystore.jks –keysize 2048

CSR (Certificate Signing Request) Generation for an Existing Java Keystore

keytool –certreg –alias mydomain –keystorekeystore.jks –file mydomain.csr

Importing Root or Intermediate Certificate to an Existing Java Keystore

keytool –import –trustcacerts –alias root –file Thawte.crt –keystorekeystore.jks

Importing of Signed Primary Certificate to an Existing Java Keystore

keytool –import –trustcacerts –alias mydomain –file mydomain.crt 
–keystorekeystore.jks

Keystore and Self-signed Certificate Generation

keytool –genkey –keyalg RSA –alias selfsigned–keystorekeystore.jks–storepass 
password –validity 360 –keysize 2048

Java Keytool Commands for Checking

Use the below commands if you want to check the information contained in a certificate.

Stand-alone Certificate

keytool –printcert –v –file mydomain.crt

Java Keystore Certificate Check

keytool –list –v –keystorekeystore.jks

Check a Particular Keystore Entry Using an Alias

keytool –list –v –keystorekeystore.jks –alias mydomain

Other Java Keytool Commands

Certificate Delete from Java Keytool Keystore

keytool –delete –alias mydomain –keystorekeystore.jks

Java Keystore Password Change

keytool –storepasswd –new new_storepass –keystorekeystore.jks

Export Certificate From a Keystore

keytool –export –alias mydomain –file mydomain.crt –keystorekeystore.jks

Trusted CA Certs List

keytool –list –v –keystore $JAVA_HOME/jre/lib/security/cacerts

New CA Import into Trusted Certs

keytool –import –trustcacerts –file /path/to/ca/ca.pem –alias CA_ALIAS 
–keystore $JAVA_HOME/jre/lib/security/cacerts


Java (programming language) Command (computing)

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

Opinions expressed by DZone contributors are their own.

Related

  • How to Modify Java Command-Line Arguments
  • JGit Library Examples in Java
  • Quickly Find Your Java Application Process ID
  • How to Kill Processes in Unix/Linux

Partner Resources

×

Comments
Oops! Something Went Wrong

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

ABOUT US

  • About DZone
  • Support and feedback
  • Community research
  • Sitemap

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 100
  • Nashville, TN 37211
  • support@dzone.com

Let's be friends:

Likes
There are no likes...yet! 👀
Be the first to like this post!
It looks like you're not logged in.
Sign in to see who liked this post!