>_ IzzyLab

Hands-on task

This task is step 9 of the course “Redis in production”

TLS for Redis with your own CA

hard~30 min

Traffic to Redis goes in plain text — passwords and data are visible to anyone sniffing the network. Enable TLS on a separate port without breaking the old one.

  1. In /etc/redis/tls/, generate your own certificate authority — ca.key and a self-signed ca.crt.
  2. Issue a server key redis.key and a certificate redis.crt signed by this CA (not self-signed) for the name localhost or the address 127.0.0.1.
  3. The key redis.key must be readable by the redis user but not readable by everyone else.
  4. In /etc/redis/redis.conf enable TLS on port 6380 (the regular port 6379 keeps working), don't require client certificates. Restart Redis.

Result: redis-cli -p 6380 --tls --cacert /etc/redis/tls/ca.crt ping replies PONG, and a client without TLS can't get through on 6380.

What you'll practise:
  • redis
  • TLS
  • openssl
  • PKI
  • certificate authority
  • tls-port

Topic breakdown

By default Redis sends commands, AUTH passwords and data in plain text. Since version 6 it supports TLS: the tls-port directive opens a separate encrypted port, tls-cert-file/tls-key-file set the server certificate, tls-ca-cert-file — the CA the server trusts when verifying clients (tls-auth-clients yes enables mutual TLS). In internal infrastructure certificates are usually issued by your own CA: a client only needs to trust its root certificate (--cacert) to verify any server. The server's private key must be readable only by the Redis process, and the old non-TLS port is kept open while clients migrate and closed afterwards (port 0).

What's checked

  1. the server certificate is signed by your CA
  2. the certificate is issued for localhost or 127.0.0.1
  3. redis can read the key, everyone else can't
  4. TLS port 6380 replies PONG
  5. no access without TLS on 6380
  6. regular port 6379 works, data intact

What it looks like