When importing a certificate chain, keytool expects the certificates to be loaded in DER form. You can create such a bundle with openssl:
1 - Convert all certificates in DER format
openssl x509 -in certificate.pem -outform DER -out certificate.crt
2 - Concat all DER certificates into one single file
cat cert1.crt cert2.crt ... > chain.der
3 - Now you can import the chain into your keystore with keytool
keytool -importcert -trustcacerts -alias <myalias> -file chain.der -keystore keystore.jks -storepass <mypassword>
Note that myalias
MUST be the same as the one used when the key was generated.
4 - verify that the chain was successfully imported
keytool -list -v -keystore keystore.jks