Languages
[Edit]
EN

keytool - generate new *.jks file (Java KeyStore repository)

9 points
Created by:
Lia-Perez
565

In this short article we would like to show how to generate *.jks file that stores security certificates as Java KeyStore repositoiry.

Quick solution (run following command):

keytool -genkey -keyalg RSA -alias my_key_alias -keystore my_keystore.jks -storepass my_secret_password -validity 3650 -keysize 2048

 

In more clear version:

keytool \
    -genkey \
    -keyalg RSA \
    -alias my_key_alias \
    -keystore my_keystore.jks \
    -storepass my_secret_password \
    -validity 3650 \
    -keysize 2048

Where:

-genkeyruns tool in key generation mode
-keyalg RSAsets RSA used as key algorithm
-alias my_key_aliassets unique allias that helps to access to keys and trusted certificate entries inside created KeyStore
-keystore my_keystore.jkssets path where Java KeyStore file is saved
-storepass my_secret_passwordsets password that protects access to store
-validity 3650

sets amount for days when generated certificates expires
(in above case it is 10 years)

-keysize 2048sets size of gnererated keys

 

keytool under Windows

Note: under Windows to get access to keytool it could be necessary to use full path.

JKD 11 keytool command example:

"C:\Program Files\Java\jdk-11.0.2\bin\keytool.exe" -genkey -keyalg RSA -alias my_key_alias -keystore my_keystore.jks -storepass my_secret_password -validity 3650 -keysize 2048

 

In more clear version:

"C:\Program Files\Java\jdk-11.0.2\bin\keytool.exe" \
    -genkey \
    -keyalg RSA \
    -alias my_key_alias \
    -keystore my_keystore.jks \
    -storepass my_secret_password \
    -validity 3650 \
    -keysize 2048

Screenshot:

Java KeyStore repositoiry (*.jks file) generating with keytool
Java KeyStore repositoiry (*.jks file) generating with keytool

 

Donate to Dirask
Our content is created by volunteers - like Wikipedia. If you think, the things we do are good, donate us. Thanks!
Join to our subscribers to be up to date with content, news and offers.
Native Advertising
🚀
Get your tech brand or product in front of software developers.
For more information Contact us
Dirask - we help you to
solve coding problems.
Ask question.

❤️💻 🙂

Join