File tree Expand file tree Collapse file tree 2 files changed +4
-2
lines changed
Expand file tree Collapse file tree 2 files changed +4
-2
lines changed Original file line number Diff line number Diff line change 6565 * Add `sum` to DUPLICATE_POLICY documentation of `TS.CREATE`, `TS.ADD` and `TS.ALTER`
6666 * Prevent async ClusterPipeline instances from becoming "false-y" in case of empty command stack (#3061)
6767 * Close Unix sockets if the connection attempt fails. This prevents `ResourceWarning`s. (#3314)
68+ * Close SSL sockets if the connection attempt fails, or if validations fail. (#3317)
6869
6970* 4.1.3 (Feb 8, 2022)
7071 * Fix flushdb and flushall (#1926)
Original file line number Diff line number Diff line change @@ -819,7 +819,7 @@ def _connect(self):
819819 sock = super ()._connect ()
820820 try :
821821 return self ._wrap_socket_with_ssl (sock )
822- except OSError :
822+ except ( OSError , RedisError ) :
823823 sock .close ()
824824 raise
825825
@@ -854,7 +854,6 @@ def _wrap_socket_with_ssl(self, sock):
854854 context .minimum_version = self .ssl_min_version
855855 if self .ssl_ciphers :
856856 context .set_ciphers (self .ssl_ciphers )
857- sslsock = context .wrap_socket (sock , server_hostname = self .host )
858857 if self .ssl_validate_ocsp is True and CRYPTOGRAPHY_AVAILABLE is False :
859858 raise RedisError ("cryptography is not installed." )
860859
@@ -864,6 +863,8 @@ def _wrap_socket_with_ssl(self, sock):
864863 "- not both."
865864 )
866865
866+ sslsock = context .wrap_socket (sock , server_hostname = self .host )
867+
867868 # validation for the stapled case
868869 if self .ssl_validate_ocsp_stapled :
869870 import OpenSSL
You can’t perform that action at this time.
0 commit comments