I have a single rootCA
certificate in the resource
folder (along with its private key) of my project.
When the software starts, it initialises the SSLManager
object, which in turn:
- Loads the rootCA into an
x509Certificate
- Loads the rootCA private key
- Generates a server keypair and certificate
- Signs the certificate using the rootCA
I would like to store the rootCA and server certificate into a keystore, that I can later use to setup an SSLContext, and for more secure storage.
I know how to store a single keypair/certificate into a keystore, but how would I correctly go about this for a chain?
I presume:
keyStore.setKeyEntry(ALIAS, privateKey, password.toCharArray, Array(rootCA, serverCert))
However, if true, which private key do I use (rootCA vs server)?
A full example would be much appreciated.