Relationship between Java certificate and keystore
I just used keytool:
keytool -genkey -keyalg RSA -alias selfsigned -keystore mykeys.jks -storepass password -validity 360 -keysize 2048
... then answered all the follow-up questions it prompted me This will generate mykeys in my local directory JKS keystore
My question: what is the relationship between this JKS file and the name of the self signed certificate contained in it? Does this mean that I now have an SSL certificate named "mykeys" in this keystore?
Additional question: can there be multiple certificates inside a single keystore (JKS file)? If so, how can I add this second SSL certificate named my2ndcert to the same JKS file?
Solution
When you create a JKS file, there is a private key entry. If no alias is specified for the key, it is MyKey by default
You can try listing JKS files to see the same key
run
keytool -list -keystore mykeys.jks -storepass <password to mykeys.jks>
A self signed certificate is what you can export from this keystore using the following command
keytool -export -alias <keyalias> -file abc.cer -keystore mykeys.jks -storepass <password to mykeys.jks>
Document ABC CER is a self signed certificate
Reward answer: Yes, one of your keystores can contain the number of keys with different aliases and multiple certificates if you import them