Last active
December 21, 2015 08:28
-
-
Save laszlomiklosik/6277886 to your computer and use it in GitHub Desktop.
keytool frequently used commands
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
1. when importing public key, a .cer file needs to be created and the X509 data must be entered between these: | |
-----BEGIN CERTIFICATE----- | |
-----END CERTIFICATE----- | |
2. import a public key: | |
keytool -keystore mykeystore.jks -storepass mykeystorepass -import -noprompt -trustcacerts -alias myserveralias -file public.cer | |
3. generate self signed x509 certificate: | |
keytool -genkey -alias clientkey -keyalg RSA -sigalg SHA1withRSA -keypass clientpass -storepass mykeystorepass -keystore mykeystore.jks -validity 365 -dname "cn=clientuser" | |
4. export a public cert from a keystore | |
keytool -exportcert -alias clientkey -keypass mykeypass -keystore mykeystore.jks -storepass mykeystorepass -rfc -file public.cer | |
5. list keystore contents | |
keytool --list -keystore mykeystore.jks -storepass mykeystorepass |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
if you want a longer validity period just add
-validity 730
to the first command, where 730 in the validity period in days starting from now