@@ -126,32 +126,40 @@ class CipherTests(tests.MySQLConnectorTests):
126
126
),
127
127
"2" : (
128
128
DeprecationWarning ,
129
- DEPRECATED_TLS_CIPHERSUITES ["TLSv1.2" ][
130
- "TLS_RSA_WITH_AES_128_GCM_SHA256"
129
+ [
130
+ DEPRECATED_TLS_CIPHERSUITES ["TLSv1.2" ][
131
+ "TLS_RSA_WITH_AES_128_GCM_SHA256"
132
+ ]
131
133
],
132
134
["TLSv1.2" ],
133
135
["TLS_RSA_WITH_AES_128_GCM_SHA256" ], # deprecated
134
136
),
135
137
"3" : (
136
138
None ,
137
- APPROVED_TLS_CIPHERSUITES ["TLSv1.2" ][
138
- "TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384"
139
+ [
140
+ APPROVED_TLS_CIPHERSUITES ["TLSv1.2" ][
141
+ "TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384"
142
+ ]
139
143
],
140
144
["TLSv1.2" ],
141
145
["ECDHE-RSA-AES256-GCM-SHA384" ], # approved
142
146
),
143
147
"4" : (
144
148
None ,
145
- MANDATORY_TLS_CIPHERSUITES ["TLSv1.2" ][
146
- "TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256"
149
+ [
150
+ MANDATORY_TLS_CIPHERSUITES ["TLSv1.2" ][
151
+ "TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256"
152
+ ]
147
153
],
148
154
["TLSv1.2" ],
149
155
["TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256" ], # mandatory
150
156
),
151
157
"5" : (
152
158
None ,
153
- MANDATORY_TLS_CIPHERSUITES ["TLSv1.2" ][
154
- "TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256"
159
+ [
160
+ MANDATORY_TLS_CIPHERSUITES ["TLSv1.2" ][
161
+ "TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256"
162
+ ]
155
163
],
156
164
["TLSv1.2" ],
157
165
[
@@ -170,14 +178,29 @@ class CipherTests(tests.MySQLConnectorTests):
170
178
),
171
179
"7" : (
172
180
None ,
173
- "TLS_AES_256_GCM_SHA384" ,
181
+ # the pure-python implementation does not support cipher selection for
182
+ # TLSv1.3. The ultimate cipher to be used will be determined by the
183
+ # MySQL Server during TLS negotiation. As of MySQL Server 9.2.0,
184
+ # `TLS_AES_128_GCM_SHA256` is used over `TLS_AES_256_GCM_SHA384` as
185
+ # default since it is more efficient.
186
+ # While AES-256 offers a higher theoretical security level due to its
187
+ # larger key size, for most practical applications, AES-128 is
188
+ # considered sufficiently secure and provides a good balance between
189
+ # security and performance. Hence, both are acceptable expected cipher
190
+ # OpenSSL name values.
191
+ [
192
+ "TLS_AES_128_GCM_SHA256" ,
193
+ "TLS_AES_256_GCM_SHA384" ,
194
+ ], # expected cipher OpenSSL name
174
195
["TLSv1.3" ],
175
196
["TLS_ECDHE_RSA_WITH_CHACHA20_POLY1305_SHA256" ], # acceptable
176
197
),
177
198
"8" : (
178
199
DeprecationWarning ,
179
- DEPRECATED_TLS_CIPHERSUITES ["TLSv1.2" ][
180
- "TLS_DHE_RSA_WITH_AES_128_GCM_SHA256"
200
+ [
201
+ DEPRECATED_TLS_CIPHERSUITES ["TLSv1.2" ][
202
+ "TLS_DHE_RSA_WITH_AES_128_GCM_SHA256"
203
+ ]
181
204
],
182
205
["TLSv1.2" ],
183
206
["TLS_DHE_RSA_WITH_AES_128_GCM_SHA256" ], # deprecated
@@ -268,7 +291,7 @@ async def _check_async_tls_ciphersuites(
268
291
return ssl_version , ssl_cipher
269
292
270
293
def _test_tls_ciphersuites (self , test_case_id : str ):
271
- exp_event , exp_ssl_cipher , tls_versions , tls_ciphersuites = (
294
+ exp_event , exp_ssl_ciphers , tls_versions , tls_ciphersuites = (
272
295
self .test_case_values ["tls_ciphersuites" ][test_case_id ]
273
296
)
274
297
@@ -290,7 +313,7 @@ def _test_tls_ciphersuites(self, test_case_id: str):
290
313
conf , exp_ssl_version
291
314
)
292
315
self .assertEqual (ssl_version , exp_ssl_version )
293
- self .assertEqual (ssl_cipher , exp_ssl_cipher )
316
+ self .assertIn (ssl_cipher , exp_ssl_ciphers )
294
317
295
318
# C-ext implementation isn't supported yet for aio.
296
319
if (CEXT_SUPPORT_FOR_AIO and not conf ["use_pure" ]) or conf ["use_pure" ]:
@@ -299,7 +322,7 @@ def _test_tls_ciphersuites(self, test_case_id: str):
299
322
self ._check_async_tls_ciphersuites (conf , exp_ssl_version )
300
323
)
301
324
self .assertEqual (ssl_version , exp_ssl_version )
302
- self .assertEqual (ssl_cipher , exp_ssl_cipher )
325
+ self .assertIn (ssl_cipher , exp_ssl_ciphers )
303
326
304
327
@tests .foreach_cnx ()
305
328
def test_tls_versions_1 (self ):
0 commit comments