DEV Community

Cover image for Useful Java KeyStore Keytool Commands
Şammas Çölkesen
Şammas Çölkesen

Posted on

1

Useful Java KeyStore Keytool Commands

Create Self-Signed Sertifika and KeyStore

>keytool -genkey -keyalg RSA -alias selfsigned -keystore keystore.jks -storepass password -validity 720

Enter fullscreen mode Exit fullscreen mode

Create CSR Certificate

>keytool -certreq -alias mydomain -keystore keystore.jks -storepass password -file mydomain.csr

Enter fullscreen mode Exit fullscreen mode

Delete Certificate from KeyStore

>keytool -delete -alias mydomain -keystore keystore.jks -storepass password
Enter fullscreen mode Exit fullscreen mode

Add Signed Primary Certificate to KeyStore

>keytool -import -trustcacerts -alias mydomain -file mycrt.crt -keystore keystore.jks
Enter fullscreen mode Exit fullscreen mode

Change KeyStore Password

>keytool -storepasswd -new new_storepass -keystore keystore.jks
Enter fullscreen mode Exit fullscreen mode

List KeyStore

>/JAVA_HOME/jre/bin/keytool -list -keystore KeyStore -storepass password
Enter fullscreen mode Exit fullscreen mode

Create Private Key

>keytool -genkey -alias KeyToolAlias -keystore privateKey.store

# Enter keystore password:
>1234

# What is your first and last name?
>John Smith
# What is the name of your organizational unit?
>Sowtware Development
# What is the name of your organization?
>dev.to
# What is the name of your City or Locality?
>Istanbul
# What is the name of your State or Province?
>Besiktas
# What is the two-letter country code for this unit?
>TR
# Is your infos correct?
>yes
Enter fullscreen mode Exit fullscreen mode

Top comments (2)

Collapse
 
me_priya profile image
Priya Mervana

@kavanozkafa The article is well-written, but I believe it would benefit from including a more comprehensive exploration of Java Keytool KeyStore Commands from here.

Collapse
 
ssl_wiki profile image
SSLWiki • Edited

@kavanozkafa Thanks for sharing this nice commands. Here're more Java Keystore Keytool Commands - sslwiki.org/java-keytool-keystore-...

Great read:

Is it Time to go Back to the Monolith?

History repeats itself. Everything old is new again and I’ve been around long enough to see ideas discarded, rediscovered and return triumphantly to overtake the fad. In recent years SQL has made a tremendous comeback from the dead. We love relational databases all over again. I think the Monolith will have its space odyssey moment again. Microservices and serverless are trends pushed by the cloud vendors, designed to sell us more cloud computing resources.

Microservices make very little sense financially for most use cases. Yes, they can ramp down. But when they scale up, they pay the costs in dividends. The increased observability costs alone line the pockets of the “big cloud” vendors.

👋 Kindness is contagious

Please leave a ❤️ or a friendly comment on this post if you found it helpful!

Okay