@@ -1209,22 +1209,38 @@ async fn create_cluster_client(
12091209 . enumerate ( )
12101210 . map ( |( i, address) | {
12111211 // DEBUG: Log certificate data for each address
1212- if let Some ( ref params) = tls_params {
1213- println ! ( "CLUSTER TLS DEBUG: Address {}: {}:{} - TLS params present" ,
1214- i, address. host, get_port( & address) ) ;
1212+ println ! ( "CLUSTER TLS DEBUG: Address {}: {}:{}" ,
1213+ i, address. host, get_port( & address) ) ;
1214+
1215+ // Create fresh TLS params for each connection instead of cloning
1216+ let fresh_tls_params = if !request. root_certs . is_empty ( ) && tls_mode != TlsMode :: NoTls {
1217+ let mut combined_certs = Vec :: new ( ) ;
1218+ for ( j, cert) in request. root_certs . iter ( ) . enumerate ( ) {
1219+ combined_certs. extend_from_slice ( cert) ;
1220+ if j < request. root_certs . len ( ) - 1 && !cert. ends_with ( b"\n " ) {
1221+ combined_certs. push ( b'\n' ) ;
1222+ }
1223+ }
1224+
1225+ let tls_certs = TlsCertificates {
1226+ client_tls : None ,
1227+ root_cert : Some ( combined_certs) ,
1228+ } ;
1229+
1230+ println ! ( "CLUSTER TLS DEBUG: Creating fresh TLS params for address {}" , i) ;
1231+ Some ( retrieve_tls_certificates ( tls_certs) ?)
12151232 } else {
1216- println ! ( "CLUSTER TLS DEBUG: Address {}: {}:{} - No TLS params" ,
1217- i, address. host, get_port( & address) ) ;
1218- }
1233+ None
1234+ } ;
12191235
12201236 get_connection_info (
12211237 & address,
12221238 tls_mode,
12231239 valkey_connection_info. clone ( ) ,
1224- tls_params . clone ( ) ,
1240+ fresh_tls_params ,
12251241 )
12261242 } )
1227- . collect ( ) ;
1243+ . collect :: < Result < Vec < _ > , _ > > ( ) ? ;
12281244
12291245 let periodic_topology_checks = match request. periodic_checks {
12301246 Some ( PeriodicCheck :: Disabled ) => None ,
0 commit comments