@@ -850,9 +850,11 @@ def __init__(
850850 ssl_exclude_verify_flags : Optional [List ["ssl.VerifyFlags" ]] = None ,
851851 ssl_ca_certs : Optional [str ] = None ,
852852 ssl_ca_data : Optional [str ] = None ,
853+ ssl_ca_path : Optional [str ] = None ,
853854 ssl_check_hostname : bool = True ,
854855 ssl_min_version : Optional [TLSVersion ] = None ,
855856 ssl_ciphers : Optional [str ] = None ,
857+ ssl_password : Optional [str ] = None ,
856858 ** kwargs ,
857859 ):
858860 if not SSL_AVAILABLE :
@@ -866,9 +868,11 @@ def __init__(
866868 exclude_verify_flags = ssl_exclude_verify_flags ,
867869 ca_certs = ssl_ca_certs ,
868870 ca_data = ssl_ca_data ,
871+ ca_path = ssl_ca_path ,
869872 check_hostname = ssl_check_hostname ,
870873 min_version = ssl_min_version ,
871874 ciphers = ssl_ciphers ,
875+ password = ssl_password ,
872876 )
873877 super ().__init__ (** kwargs )
874878
@@ -923,10 +927,12 @@ class RedisSSLContext:
923927 "exclude_verify_flags" ,
924928 "ca_certs" ,
925929 "ca_data" ,
930+ "ca_path" ,
926931 "context" ,
927932 "check_hostname" ,
928933 "min_version" ,
929934 "ciphers" ,
935+ "password" ,
930936 )
931937
932938 def __init__ (
@@ -938,9 +944,11 @@ def __init__(
938944 exclude_verify_flags : Optional [List ["ssl.VerifyFlags" ]] = None ,
939945 ca_certs : Optional [str ] = None ,
940946 ca_data : Optional [str ] = None ,
947+ ca_path : Optional [str ] = None ,
941948 check_hostname : bool = False ,
942949 min_version : Optional [TLSVersion ] = None ,
943950 ciphers : Optional [str ] = None ,
951+ password : Optional [str ] = None ,
944952 ):
945953 if not SSL_AVAILABLE :
946954 raise RedisError ("Python wasn't built with SSL support" )
@@ -965,11 +973,13 @@ def __init__(
965973 self .exclude_verify_flags = exclude_verify_flags
966974 self .ca_certs = ca_certs
967975 self .ca_data = ca_data
976+ self .ca_path = ca_path
968977 self .check_hostname = (
969978 check_hostname if self .cert_reqs != ssl .CERT_NONE else False
970979 )
971980 self .min_version = min_version
972981 self .ciphers = ciphers
982+ self .password = password
973983 self .context : Optional [SSLContext ] = None
974984
975985 def get (self ) -> SSLContext :
@@ -983,10 +993,16 @@ def get(self) -> SSLContext:
983993 if self .exclude_verify_flags :
984994 for flag in self .exclude_verify_flags :
985995 context .verify_flags &= ~ flag
986- if self .certfile and self .keyfile :
987- context .load_cert_chain (certfile = self .certfile , keyfile = self .keyfile )
988- if self .ca_certs or self .ca_data :
989- context .load_verify_locations (cafile = self .ca_certs , cadata = self .ca_data )
996+ if self .certfile or self .keyfile :
997+ context .load_cert_chain (
998+ certfile = self .certfile ,
999+ keyfile = self .keyfile ,
1000+ password = self .password ,
1001+ )
1002+ if self .ca_certs or self .ca_data or self .ca_path :
1003+ context .load_verify_locations (
1004+ cafile = self .ca_certs , capath = self .ca_path , cadata = self .ca_data
1005+ )
9901006 if self .min_version is not None :
9911007 context .minimum_version = self .min_version
9921008 if self .ciphers is not None :
@@ -1239,16 +1255,17 @@ def can_get_connection(self) -> bool:
12391255 version = "5.3.0" ,
12401256 )
12411257 async def get_connection (self , command_name = None , * keys , ** options ):
1258+ """Get a connected connection from the pool"""
12421259 async with self ._lock :
1243- """Get a connected connection from the pool"""
12441260 connection = self .get_available_connection ()
1245- try :
1246- await self .ensure_connection (connection )
1247- except BaseException :
1248- await self .release (connection )
1249- raise
12501261
1251- return connection
1262+ # We now perform the connection check outside of the lock.
1263+ try :
1264+ await self .ensure_connection (connection )
1265+ return connection
1266+ except BaseException :
1267+ await self .release (connection )
1268+ raise
12521269
12531270 def get_available_connection (self ):
12541271 """Get a connection from the pool, without making sure it is connected"""
0 commit comments