EN
keytool - generate new *.jks file (Java KeyStore repository)
9
points
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:
-genkey | runs tool in key generation mode |
-keyalg RSA | sets RSA used as key algorithm |
-alias my_key_alias | sets unique allias that helps to access to keys and trusted certificate entries inside created KeyStore |
-keystore my_keystore.jks | sets path where Java KeyStore file is saved |
-storepass my_secret_password | sets password that protects access to store |
-validity 3650 |
sets amount for days when generated certificates expires |
-keysize 2048 | sets 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: