Languages
[Edit]
EN

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

9 points
Created by:
AnnLen
9180

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
Native Advertising
50 000 ad impressions - 449$
🚀
Get your tech brand or product in front of software developers.
For more information contact us:
Red dot
Dirask - friendly IT community for everyone.

❤️💻 🙂

Join