Skip to content

Commit c5d38a5

Browse files
Fix CPython patches (#1515)
Fix needed after upstream [PR #117351][1]. [1]: python/cpython#117351
1 parent c932cf4 commit c5d38a5

File tree

3 files changed

+17
-44
lines changed

3 files changed

+17
-44
lines changed

tests/ci/integration/python_patch/3.10/aws-lc-cpython.patch

+17-20
Original file line numberDiff line numberDiff line change
@@ -66,7 +66,7 @@ index b5c78a5..41235c1 100644
6666
client = self.imap_class(*server.server_address,
6767
ssl_context=ssl_context)
6868
diff --git a/Lib/test/test_ssl.py b/Lib/test/test_ssl.py
69-
index a1a581a..c69e711 100644
69+
index a1a581a..6f42437 100644
7070
--- a/Lib/test/test_ssl.py
7171
+++ b/Lib/test/test_ssl.py
7272
@@ -44,6 +44,7 @@
@@ -253,19 +253,16 @@ index a1a581a..c69e711 100644
253253

254254
def test_version_basic(self):
255255
"""
256-
@@ -4004,7 +4016,10 @@ def test_min_max_version_mismatch(self):
256+
@@ -4004,7 +4016,7 @@ def test_min_max_version_mismatch(self):
257257
server_hostname=hostname) as s:
258258
with self.assertRaises(ssl.SSLError) as e:
259259
s.connect((HOST, server.port))
260260
- self.assertIn("alert", str(e.exception))
261-
+ self.assertTrue(
262-
+ "alert"in str(e.exception)
263-
+ or "ALERT"in str(e.exception)
264-
+ )
261+
+ self.assertRegex(str(e.exception), "(alert|ALERT)")
265262

266263
@requires_tls_version('SSLv3')
267264
def test_min_max_version_sslv3(self):
268-
@@ -4046,6 +4061,9 @@ def test_tls_unique_channel_binding(self):
265+
@@ -4046,6 +4058,9 @@ def test_tls_unique_channel_binding(self):
269266

270267
client_context, server_context, hostname = testing_context()
271268

@@ -275,15 +272,15 @@ index a1a581a..c69e711 100644
275272
server = ThreadedEchoServer(context=server_context,
276273
chatty=True,
277274
connectionchatty=False)
278-
@@ -4118,6 +4136,7 @@ def test_compression_disabled(self):
275+
@@ -4118,6 +4133,7 @@ def test_compression_disabled(self):
279276
self.assertIs(stats['compression'], None)
280277

281278
@unittest.skipIf(Py_DEBUG_WIN32, "Avoid mixing debug/release CRT on Windows")
282279
+ @unittest.skipIf(Py_OPENSSL_IS_AWSLC, "AWS-LC doesn't support (FF)DHE")
283280
def test_dh_params(self):
284281
# Check we can get a connection with ephemeral Diffie-Hellman
285282
client_context, server_context, hostname = testing_context()
286-
@@ -4132,7 +4151,7 @@ def test_dh_params(self):
283+
@@ -4132,7 +4148,7 @@ def test_dh_params(self):
287284
cipher = stats["cipher"][0]
288285
parts = cipher.split("-")
289286
if "ADH" not in parts and "EDH" not in parts and "DHE" not in parts:
@@ -292,7 +289,7 @@ index a1a581a..c69e711 100644
292289

293290
def test_ecdh_curve(self):
294291
# server secp384r1, client auto
295-
@@ -4299,8 +4318,10 @@ def cb_raising(ssl_sock, server_name, initial_context):
292+
@@ -4299,8 +4315,10 @@ def cb_raising(ssl_sock, server_name, initial_context):
296293
chatty=False,
297294
sni_name='supermessage')
298295

@@ -305,7 +302,7 @@ index a1a581a..c69e711 100644
305302
self.assertEqual(catch.unraisable.exc_type, ZeroDivisionError)
306303

307304
def test_sni_callback_wrong_return_type(self):
308-
@@ -4476,7 +4497,10 @@ def test_session_handling(self):
305+
@@ -4476,7 +4494,10 @@ def test_session_handling(self):
309306
'Session refers to a different SSLContext.')
310307

311308

@@ -317,7 +314,7 @@ index a1a581a..c69e711 100644
317314
class TestPostHandshakeAuth(unittest.TestCase):
318315
def test_pha_setter(self):
319316
protocols = [
320-
@@ -4752,6 +4776,31 @@ def test_internal_chain_server(self):
317+
@@ -4752,6 +4773,31 @@ def test_internal_chain_server(self):
321318
self.assertEqual(res, b'\x02\n')
322319

323320

@@ -350,7 +347,7 @@ index a1a581a..c69e711 100644
350347
requires_keylog = unittest.skipUnless(
351348
HAS_KEYLOG, 'test requires OpenSSL 1.1.1 with keylog callback')
352349
diff --git a/Modules/Setup b/Modules/Setup
353-
index 87c6a15..f67d7ec 100644
350+
index 87c6a15..1a7257c 100644
354351
--- a/Modules/Setup
355352
+++ b/Modules/Setup
356353
@@ -208,8 +208,8 @@ _symtable symtablemodule.c
@@ -403,7 +400,7 @@ index 35addf4..77a12c6 100644
403400
};
404401

405402
diff --git a/Modules/_ssl.c b/Modules/_ssl.c
406-
index 7a28f2d..b0d2ea1 100644
403+
index e637830..dc99dd8 100644
407404
--- a/Modules/_ssl.c
408405
+++ b/Modules/_ssl.c
409406
@@ -181,6 +181,12 @@ extern const SSL_METHOD *TLSv1_2_method(void);
@@ -454,7 +451,7 @@ index 7a28f2d..b0d2ea1 100644
454451
if (ret < 1)
455452
return PySSL_SetError(self, ret, __FILE__, __LINE__);
456453
if (PySSL_ChainExceptions(self) < 0)
457-
@@ -2771,7 +2783,7 @@ static PyObject *
454+
@@ -2771,7 +2778,7 @@ static PyObject *
458455
_ssl__SSLSocket_verify_client_post_handshake_impl(PySSLSocket *self)
459456
/*[clinic end generated code: output=532147f3b1341425 input=6bfa874810a3d889]*/
460457
{
@@ -463,7 +460,7 @@ index 7a28f2d..b0d2ea1 100644
463460
int err = SSL_verify_client_post_handshake(self->ssl);
464461
if (err == 0)
465462
return _setSSLError(get_state_sock(self), NULL, 0, __FILE__, __LINE__);
466-
@@ -3199,7 +3211,7 @@ _ssl__SSLContext_impl(PyTypeObject *type, int proto_version)
463+
@@ -3199,7 +3206,7 @@ _ssl__SSLContext_impl(PyTypeObject *type, int proto_version)
467464
X509_VERIFY_PARAM_set_flags(params, X509_V_FLAG_TRUSTED_FIRST);
468465
X509_VERIFY_PARAM_set_hostflags(params, self->hostflags);
469466

@@ -472,7 +469,7 @@ index 7a28f2d..b0d2ea1 100644
472469
self->post_handshake_auth = 0;
473470
SSL_CTX_set_post_handshake_auth(self->ctx, self->post_handshake_auth);
474471
#endif
475-
@@ -3573,7 +3585,7 @@ set_maximum_version(PySSLContext *self, PyObject *arg, void *c)
472+
@@ -3573,7 +3580,7 @@ set_maximum_version(PySSLContext *self, PyObject *arg, void *c)
476473
return set_min_max_proto_version(self, arg, 1);
477474
}
478475

@@ -481,7 +478,7 @@ index 7a28f2d..b0d2ea1 100644
481478
static PyObject *
482479
get_num_tickets(PySSLContext *self, void *c)
483480
{
484-
@@ -3604,7 +3616,7 @@ set_num_tickets(PySSLContext *self, PyObject *arg, void *c)
481+
@@ -3604,7 +3611,7 @@ set_num_tickets(PySSLContext *self, PyObject *arg, void *c)
485482

486483
PyDoc_STRVAR(PySSLContext_num_tickets_doc,
487484
"Control the number of TLSv1.3 session tickets");
@@ -490,7 +487,7 @@ index 7a28f2d..b0d2ea1 100644
490487

491488
static PyObject *
492489
get_security_level(PySSLContext *self, void *c)
493-
@@ -3694,14 +3706,14 @@ set_check_hostname(PySSLContext *self, PyObject *arg, void *c)
490+
@@ -3694,14 +3701,14 @@ set_check_hostname(PySSLContext *self, PyObject *arg, void *c)
494491

495492
static PyObject *
496493
get_post_handshake_auth(PySSLContext *self, void *c) {
@@ -507,7 +504,7 @@ index 7a28f2d..b0d2ea1 100644
507504
static int
508505
set_post_handshake_auth(PySSLContext *self, PyObject *arg, void *c) {
509506
if (arg == NULL) {
510-
@@ -4651,14 +4663,14 @@ static PyGetSetDef context_getsetlist[] = {
507+
@@ -4706,14 +4713,14 @@ static PyGetSetDef context_getsetlist[] = {
511508
(setter) _PySSLContext_set_msg_callback, NULL},
512509
{"sni_callback", (getter) get_sni_callback,
513510
(setter) set_sni_callback, PySSLContext_sni_callback_doc},

tests/ci/integration/python_patch/3.12/aws-lc-cpython.patch

-12
Original file line numberDiff line numberDiff line change
@@ -32,18 +32,6 @@ index f3960be..ffd360b 100644
3232
def seclevel_workaround(*ctxs):
3333
""""Lower security level to '1' and allow all ciphers for TLS 1.0/1"""
3434
for ctx in ctxs:
35-
@@ -3822,7 +3823,10 @@ def test_min_max_version_mismatch(self):
36-
server_hostname=hostname) as s:
37-
with self.assertRaises(ssl.SSLError) as e:
38-
s.connect((HOST, server.port))
39-
- self.assertRegex("(alert|ALERT)", str(e.exception))
40-
+ self.assertTrue(
41-
+ "alert"in str(e.exception)
42-
+ or "ALERT"in str(e.exception)
43-
+ )
44-
45-
@requires_tls_version('SSLv3')
46-
def test_min_max_version_sslv3(self):
4735
@@ -3954,6 +3958,7 @@ def test_no_legacy_server_connect(self):
4836
sni_name=hostname)
4937

tests/ci/integration/python_patch/main/aws-lc-cpython.patch

-12
Original file line numberDiff line numberDiff line change
@@ -32,18 +32,6 @@ index 3fa806d..0983212 100644
3232
def seclevel_workaround(*ctxs):
3333
""""Lower security level to '1' and allow all ciphers for TLS 1.0/1"""
3434
for ctx in ctxs:
35-
@@ -3865,7 +3866,10 @@ def test_min_max_version_mismatch(self):
36-
server_hostname=hostname) as s:
37-
with self.assertRaises(ssl.SSLError) as e:
38-
s.connect((HOST, server.port))
39-
- self.assertRegex("(alert|ALERT)", str(e.exception))
40-
+ self.assertTrue(
41-
+ "alert"in str(e.exception)
42-
+ or "ALERT"in str(e.exception)
43-
+ )
44-
45-
@requires_tls_version('SSLv3')
46-
def test_min_max_version_sslv3(self):
4735
@@ -3997,6 +4001,7 @@ def test_no_legacy_server_connect(self):
4836
sni_name=hostname)
4937

0 commit comments

Comments
 (0)