Advertisement
Intermediate Redis, TLS & Encryption in Redis

How do you configure a Redis client application, such as one using the redis-py library, to connect over TLS?

Short answer

You pass connection parameters that specify the TLS scheme along with paths to the client certificate, private key, and certificate authority file, allowing the client library to establish an encrypted and authenticated connection before sending any commands to the server.

Save Redis mock interview
Advertisement
AModel answer
You pass connection parameters that specify the TLS scheme along with paths to the client certificate, private key, and certificate authority file, allowing the client library to establish an encrypted and authenticated connection before sending any commands to the server.
import redis
_client = redis.Redis(
    host='redis.example.com', port=6379, ssl=True,
    ssl_certfile='client.crt', ssl_keyfile='client.key',
    ssl_ca_certs='ca.crt')
Real-world example
A backend service configures its Redis client library with the required TLS certificates at startup, ensuring every connection it opens to the Redis cluster is encrypted from the very first command.
Likely follow-ups
  • What happens if the client certificate has expired?
  • Is there a performance cost to using TLS connections compared to plain TCP?
Related topics