@@ -139,6 +139,21 @@ class PeriodicChecksStatus(Enum):
139
139
"""
140
140
141
141
142
+ class TlsAdvancedConfiguration :
143
+ """
144
+ Represents advanced TLS configuration settings.
145
+
146
+ Attributes:
147
+ insecure (Optional[bool]): Indicates whether to bypass TLS certificate verification.
148
+ When set to True, the client will bypass certificate validation (for example, when connecting
149
+ to servers with self-signed or unauthorized certificates). This setting is useful for development
150
+ or testing environments, but should not be used in production due to security risks.
151
+ """
152
+
153
+ def __init__ (self , insecure : Optional [bool ] = None ):
154
+ self .insecure = insecure
155
+
156
+
142
157
class AdvancedBaseClientConfiguration :
143
158
"""
144
159
Represents the advanced configuration settings for a base Glide client.
@@ -148,29 +163,30 @@ class AdvancedBaseClientConfiguration:
148
163
This applies both during initial client creation and any reconnections that may occur during request processing.
149
164
**Note**: A high connection timeout may lead to prolonged blocking of the entire command pipeline.
150
165
If not explicitly set, a default value of 250 milliseconds will be used.
151
- tls_insecure (Optional[bool]): The TLS state; defaults to secured (False).
152
- When set to True, the client will bypass certificate verification, allowing connections to
153
- Valkey/Redis instances with self-signed or otherwise unauthorized certificates.
154
- This option is intended for local development or testing environments where a valid
155
- certificate may not be available. It is not recommended for production use,
156
- as disabling certificate validation exposes the connection to potential security
157
- risks such as man-in-the-middle attacks.
166
+ tls_config (Optional[TlsAdvancedConfiguration]): The advanced TLS configuration settings.
167
+ This allows for more granular control of TLS behavior, such as enabling an insecure mode
168
+ that bypasses certificate validation.
158
169
"""
159
170
160
171
def __init__ (
161
172
self ,
162
173
connection_timeout : Optional [int ] = None ,
163
- tls_insecure : Optional [bool ] = None ,
174
+ tls_config : Optional [TlsAdvancedConfiguration ] = None ,
164
175
):
165
176
self .connection_timeout = connection_timeout
166
- self .tls_insecure = tls_insecure
177
+ self .tls_config = tls_config
167
178
168
179
def _create_a_protobuf_conn_request (
169
180
self , request : ConnectionRequest
170
181
) -> ConnectionRequest :
171
182
if self .connection_timeout :
172
183
request .connection_timeout = self .connection_timeout
173
- if True == self .tls_insecure and TlsMode .SecureTls == request .tls_mode :
184
+
185
+ if (
186
+ self .tls_config
187
+ and self .tls_config .insecure
188
+ and request .tls_mode == TlsMode .SecureTls
189
+ ):
174
190
request .tls_mode = TlsMode .InsecureTls
175
191
176
192
return request
@@ -186,7 +202,7 @@ class BaseClientConfiguration:
186
202
the cluster and find all nodes.
187
203
If the server is in standalone mode, only nodes whose addresses were provided will be used by the
188
204
client.
189
- For example:
205
+ For example::
190
206
191
207
[
192
208
{address:sample-address-0001.use1.cache.amazonaws.com, port:6379},
@@ -311,10 +327,10 @@ class AdvancedGlideClientConfiguration(AdvancedBaseClientConfiguration):
311
327
def __init__ (
312
328
self ,
313
329
connection_timeout : Optional [int ] = None ,
314
- tls_insecure : Optional [bool ] = None ,
330
+ tls_config : Optional [TlsAdvancedConfiguration ] = None ,
315
331
):
316
332
317
- super ().__init__ (connection_timeout , tls_insecure )
333
+ super ().__init__ (connection_timeout , tls_config )
318
334
319
335
320
336
class GlideClientConfiguration (BaseClientConfiguration ):
@@ -487,9 +503,9 @@ class AdvancedGlideClusterClientConfiguration(AdvancedBaseClientConfiguration):
487
503
def __init__ (
488
504
self ,
489
505
connection_timeout : Optional [int ] = None ,
490
- tls_insecure : Optional [bool ] = None ,
506
+ tls_config : Optional [TlsAdvancedConfiguration ] = None ,
491
507
):
492
- super ().__init__ (connection_timeout , tls_insecure )
508
+ super ().__init__ (connection_timeout , tls_config )
493
509
494
510
495
511
class GlideClusterClientConfiguration (BaseClientConfiguration ):
0 commit comments