redis / redis-py

Redis Python client
MIT License
12.69k stars 2.53k forks source link

Implement ssl_ca_path argument for async Redis client #3414

Open tyler-8 opened 1 month ago

tyler-8 commented 1 month ago

Version: redis-py 5.0.3

Platform: Ubuntu 22

Description: The sync redis client supports the ssl_ca_path argument to point to a directory of certificate authority certs. However, the async redis client does not support this argument. The workarounds for this are messy or come with their own challenges and the best solution would be for the async and sync clients to match.

Gerioso commented 1 month ago

I solved this problem by using : 1)cluster

        from redis.asyncio import RedisCluster
        from redis.asyncio.cluster import ClusterNode
        pool = RedisCluster(
        startup_nodes=cluster_hosts,
        password=*redis_password*,
        ssl=True,
        ssl_ca_certs=* ssl_ca_path*,
        decode_responses=True,
    ) 

2)pool

    pool = ConnectionPool(
        host= redis_host,
        port=redis_port,
        password=redis_password,
        db=0,
        decode_responses=True,
        connection_class=SSLConnection,
        ssl_ca_certs=ssl_ca_path,
    )
tyler-8 commented 1 month ago

I solved this problem by using...

The ssl_ca_certs argument is passed into the cafile argument in context.load_verify_locations(cafile=self.ca_certs, cadata=self.ca_data) which expects a single file, not a directory.