Open dfroger opened 3 months ago
So redis-py
actually use pyopenssl (not Python ssl
stdlib module). Seems I need to call OpenSSL.SSL.Connection.set_tlsext_host_name(name).
Edit: it uses both.
Just found that: https://github.com/redis/redis-py/pull/1087
In redis/connection.py:SSLConnection._wrap_socket_with_ssl
:
sslsock = context.wrap_socket(sock, server_hostname=self.host)
con.connect((self.host, self.port))
I would have expected the SNI passed in wrap_socket
to be possibly different of the TCP host we connect to.
Hi,
I'm trying to proxy with Traefik multiple Redis instances, that run in different Docker Swarm stacks.
Traefik provide HostSNI rule to route a TCP connection to the corresponding Docker container.
So my goal would be to establish with
redis-py
a Redis connection with SSL providing theServer Name Identification
.This seems to be possible with ssl.SSLContext.wrap_socket:
Then
redis-py
documents examples on how to pass anSSLContext
with thessl_ocsp_context=ctx
argument, so it seems feasible to achieve.Does it sound good? May in the future a
ssl_server_name
argument be added toredis.Redis()
to simplify the usage?I should provide feedback of my experiment on this soon.
Thanks for reading!