I am using below commands:
openssl req -new -newkey -keyout example.key
openssl dhparam -out example.pem
I submit the csr (also generated by openssl not shown above) file to CA which reply with a text file named sighned certificate. This text file has 4 sections each section starts with —-BEGIN CERTIFICATE—- and ends with —–END CERTIFICATE——
Does the first section map to ROOT CERTIFICATE? Does the third section map to INTERMEDIATE CERTIFICATE? What the last section maps to?
I also use keytool to generate keystore.jks file. What is jks file and why it is needed?
Now in redis TLS docs
tls-cert-file /path/to/redis.crt
tls-key-file /path/to/redis.key
tls-ca-cert-file /path/to/ca.crt
tls-dh-params-file /path/to/redis.dh
What files I use to plugin in above settings?
What is the difference between tls-cert-file and tls-ca-cert-file?
2
Answers
Refer from redis-src/utils/gen-test-certs.sh:
You can use this script to generate redis.crt, redis.key, ca.crt and redis.dh.
CSR RESPONSE DATA
If you have 4 files returned from the certificate signing request, then I would expect them to be as follows,
The first 3 of these should have this format, representing a public key:
I would expect the 4th file to have a different format, representing a private key:
For each public key, paste them into the GoDaddy online certificate viewer. The output text will enable you to distinguish between the role of each certificate, to ensure that you’ve identified them correctly.
APPLY CERTIFICATE FILES TO REDIS
Then assign values for redis as follows. The
tls-cert-file
is exposed to redis clients, to represent the public part of the redis server’s TLS identity. Thetls-ca-cert-file
is also exposed to clients, and represents the public part of the TLS identity for issuing authorities:The
trusted.crt
file is a bundle file consisting of root and intermediate certificate authorities. It is formed by concatenating the root public key followed by the intermediate public key:CERTIFICATE CREATION
Sometimes it can be useful to create your own development certificates, to better understand the process, without requiring infrastructure. You can generate all 3 types of file using openssl. See this script of mine for an example.
I would aim to avoid JKS files. They are a Java specific layer on top of the PKI and a less portable concept. You should not need it to get redis working over TLS. Similarly, dhparams is a more advanced option used for key agreement between client and server. You should not need this if you just want to secure redis via TLS.
CERTIFICATE TRUST
You also need to manage client connections to redis. They will need to trust the root and intermediate certificates also, but the exact way you configure this will depend on the technology stack of the client.
Trust can be established by either trusting the
trusted.ca.crt
file, or trusting both theroot.crt
andintermediate.crt
files. My blog post has some examples of configuring trust in clients.