Firstly, there's no guarantee that the p12 file you have contains the CA certificate with which the End Entity Certificate it contains was issued. Although it is useful for a keystore to contain intermediate certificate (as discussed here), containing the CA at the end of the chain is not necessary: if the remote party doesn't trust it, adding it to the chain won't make a difference (as discussed here).
You can check this using openssl pkcs12 -nokeys -out output.pem -in yourstore.p12
. Look at the content of output.pem
with a text editor, you should see whether the CA certificate is included. If not, contact the CA that issued your certificate, they should be able to provide it to you.
Then, to build a new keystore to use as a truststore, use keytool -import
, for example keytool -import -keystore mytruststore.jks -file the_ca_file.pem
. (That CA file should only contain the certificate of the CA, not the others. If you're copying this from the previous output, only use the relevant --BEGIN--...--END--
block.)
You're not saying whether you want this truststore to be used for authenticating clients connecting to your Tomcat server, or to be used for connections made by webapps running within Tomcat (in which case they're clients). Where and how to set up this truststore will depend on it. (In the second case, it's often useful to start from a copy of the default cacerts
file, instead of creating a new store from scratch.)