Typically a certificate chain, which is what you now have, only makes sense in association with a Private Key. "JKS" is a particular keystore format, whose entries match those described by the Java KeyStore
javadocs. See the description for KeyStore.PrivateKeyEntry
in the KeyStore
docs. You'd already have the private key in the JKS keystore. Thus a typical flow is something like the following:
keytool -genkeypair -keystore myks.jks -alias server1
keytool -certreq -keystore myks.jks -alias server1 -file server1.p10
server1.p10
contains a PKCS#10 certificate request. Included in that is the public key that corresponds to the private key in alias server1
in the keystore. Now you'd take the file server1.p10
and supply it to your certificate authority (CA). If all is well they'll return to you a file containing a properly signed leaf certificate and 0 or more intermediate certificates. This is likely to be the file keystore.txt
you are referring to. (Note that all reputable SSL CAs I am aware of will always include at least 1 intermediate cert along with your leaf cert).
You then import these certificates into the keystore, specifying the alias that corresponds to the correct private key, with the following command.
keytool -importcert -keystore myks.jks -alias server1
And this completes the transaction. The keystore now contains a private key and associated certificate chain accessible through the alias server1
.