File tree Expand file tree Collapse file tree 3 files changed +49
-5
lines changed Expand file tree Collapse file tree 3 files changed +49
-5
lines changed Original file line number Diff line number Diff line change @@ -3,6 +3,19 @@ Changelog
3
3
4
4
Versions are year-based with a strict backward-compatibility policy.
5
5
The third digit is only for regressions.
6
+ UNRELEASED
7
+ ----------
8
+
9
+ Backward-incompatible changes:
10
+ ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
11
+
12
+ Deprecations:
13
+ ^^^^^^^^^^^^^
14
+
15
+ Changes:
16
+ ^^^^^^^^
17
+
18
+ - Added ``OpenSSL.SSL.Context.set_ciphersuites `` that allows the allowed TLS 1.3 ciphers.
6
19
7
20
25.1.0 (2025-05-17)
8
21
-------------------
Original file line number Diff line number Diff line change @@ -1468,6 +1468,9 @@ def set_cipher_list(self, cipher_list: bytes) -> None:
1468
1468
See the OpenSSL manual for more information (e.g.
1469
1469
:manpage:`ciphers(1)`).
1470
1470
1471
+ Note this API does not change the cipher suites used in TLS 1.3
1472
+ Use `set_ciphersuites` for that.
1473
+
1471
1474
:param bytes cipher_list: An OpenSSL cipher string.
1472
1475
:return: None
1473
1476
"""
@@ -1500,6 +1503,31 @@ def set_cipher_list(self, cipher_list: bytes) -> None:
1500
1503
],
1501
1504
)
1502
1505
1506
+ @_require_not_used
1507
+ def set_ciphersuites (self , ciphersuites : bytes ) -> None :
1508
+ """
1509
+ Set the list of TLS 1.3 ciphers to be used in this context.
1510
+ OpenSSL maintains a separate list of TLS 1.3+ ciphers to
1511
+ ciphers for TLS 1.2 and lowers.
1512
+
1513
+ See the OpenSSL manual for more information (e.g.
1514
+ :manpage:`ciphers(1)`).
1515
+
1516
+ :param bytes ciphersuites: An OpenSSL cipher string containing
1517
+ TLS 1.3+ ciphersuites.
1518
+ :return: None
1519
+
1520
+ .. versionadded:: 25.2.0
1521
+ """
1522
+ ciphersuites = _text_to_bytes_and_warn ("ciphersuites" , ciphersuites )
1523
+
1524
+ if not isinstance (ciphersuites , bytes ):
1525
+ raise TypeError ("ciphersuites must be a byte string." )
1526
+
1527
+ _openssl_assert (
1528
+ _lib .SSL_CTX_set_ciphersuites (self ._context , ciphersuites ) == 1
1529
+ )
1530
+
1503
1531
@_require_not_used
1504
1532
def set_client_ca_list (
1505
1533
self , certificate_authorities : Sequence [X509Name ]
Original file line number Diff line number Diff line change @@ -497,20 +497,23 @@ class TestContext:
497
497
498
498
@pytest .mark .parametrize (
499
499
"cipher_string" ,
500
- [b"hello world:AES128-SHA " , "hello world:AES128-SHA " ],
500
+ [b"TLS_AES_128_GCM_SHA256 " , "TLS_AES_128_GCM_SHA256 " ],
501
501
)
502
- def test_set_cipher_list (
502
+ def test_set_ciphersuites (
503
503
self , context : Context , cipher_string : bytes
504
504
) -> None :
505
505
"""
506
- `Context.set_cipher_list ` accepts both byte and unicode strings
506
+ `Context.set_ciphersuites ` accepts both byte and unicode strings
507
507
for naming the ciphers which connections created with the context
508
508
object will be able to choose from.
509
509
"""
510
- context .set_cipher_list (cipher_string )
510
+ context .set_ciphersuites (cipher_string )
511
511
conn = Connection (context , None )
512
512
513
- assert "AES128-SHA" in conn .get_cipher_list ()
513
+ # OpenSSL has different APIs for *setting* TLS <=1.2 and >= 1.3
514
+ # but only one API for retrieving them
515
+ assert "TLS_AES_128_GCM_SHA256" in conn .get_cipher_list ()
516
+ assert "TLS_AES_256_GCM_SHA384" not in conn .get_cipher_list ()
514
517
515
518
def test_set_cipher_list_wrong_type (self , context : Context ) -> None :
516
519
"""
You can’t perform that action at this time.
0 commit comments