redis / redis-py

Redis Python client
MIT License
12.66k stars 2.52k forks source link

Sentinel TLS: discover_master is not respect connection type. #3128

Open garry-t opened 9 months ago

garry-t commented 9 months ago

In case Sentinel configured with TLS , redis_master call fails with error: "Connection reset by peer", means it is not use TLS during function call. I've checked all docs which I able to found and for me still not clear is it supported or no? Version: 5.1.0b3

Platform: Python 3.11 MacOS

Description: SSL were generated self signed. My simple code:

 sentinel = Sentinel(
            sentinels=sentinel_addresses,
            sentinel_kwargs={'password': secret_file_data['password']},
            socket_timeout=0.1,
            ssl=True,
            ssl_keyfile=ssl_keyfile,
            ssl_certfile=ssl_certfile,
            ssl_ca_certs=ssl_ca_certs
        )
 host, port = sentinel.discover_master(master_name)
 master = sentinel.master_for(master_name, password=secret_file_data['password'])
 print(f"Current {'SSL' if use_ssl else 'Non-SSL'} Connection - Master IP: {host}")

In sentinel logs

Error accepting a client connection: error:1408F10B:SSL routines:ssl3_get_record:wrong version number (addr=IP:56828 laddr=IP:26380)

erihu78 commented 2 months ago

I have exactly the same issue! Any news on this??

garionphx commented 2 months ago

I ran into a similar problem, only with authentication. I created a merge request that fixes my issue, and maybe yours also: https://github.com/redis/redis-py/pull/3376

rad-pat commented 4 weeks ago

Don't you fix this by passing the necessary ssl kwargs into the sentinel_kwargs?