We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
There was an error while loading. Please reload this page.
1 parent 404405a commit 1634946Copy full SHA for 1634946
redis/connection.py
@@ -834,8 +834,26 @@ def __init__(
834
super().__init__(**kwargs)
835
836
def _connect(self):
837
- "Wrap the socket with SSL support"
+ """
838
+ Wrap the socket with SSL support, handling potential errors.
839
840
sock = super()._connect()
841
+ try:
842
+ return self._wrap_socket_with_ssl(sock)
843
+ except OSError:
844
+ sock.close()
845
+ raise
846
+
847
+ def _wrap_socket_with_ssl(self, sock):
848
849
+ Wraps the socket with SSL support.
850
851
+ Args:
852
+ sock: The plain socket to wrap with SSL.
853
854
+ Returns:
855
+ An SSL wrapped socket.
856
857
context = ssl.create_default_context()
858
context.check_hostname = self.check_hostname
859
context.verify_mode = self.cert_reqs
0 commit comments