Java Keytool Examples

Creating a RSA Self-Signed Certificate w/ PKCS Keystore

RSA Self Signed Certificate (Testing) w/ PKCS12 Keystore

Here is how to create Self Signed (Testing) Certificate
 Copy keytool -genkeypair -keysize 4096 -sigalg SHA512withRSA -keyalg RSA -alias serverkey -keypass changeit -validity 365 -dname "CN=TESTING,OU=IT,O=Mega,L=Planet,ST=CO,C=US" -storetype pkcs12 -keystore that.keystore -storepass changeit -ext san=dns:server.example.com,dns:server,ip:10.10.10.10,ip:::1 
Check the keys and keystore creation
 Copy keytool -list -v -keystore that.keystore -storetype pkcs12 -storepass changeit 
Export the Self Signed (Testing) Certificate.
 Copy keytool -exportcert -alias serverkey -file TESTCert.pem -storetype pkcs12 -keystore that.keystore -storepass changeit -rfc 
Check Self Signed (Testing) Certificate.
 Copy keytool -printcert -v -file TESTCert.pem