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 @@ -1469,6 +1469,9 @@ def set_cipher_list(self, cipher_list: bytes) -> None:
1469
1469
See the OpenSSL manual for more information (e.g.
1470
1470
:manpage:`ciphers(1)`).
1471
1471
1472
+ Note this API does not change the cipher suites used in TLS 1.3
1473
+ Use `set_ciphersuites` for that.
1474
+
1472
1475
:param bytes cipher_list: An OpenSSL cipher string.
1473
1476
:return: None
1474
1477
"""
@@ -1501,6 +1504,31 @@ def set_cipher_list(self, cipher_list: bytes) -> None:
1501
1504
],
1502
1505
)
1503
1506
1507
+ @_require_not_used
1508
+ def set_ciphersuites (self , ciphersuites : bytes ) -> None :
1509
+ """
1510
+ Set the list of TLS 1.3 ciphers to be used in this context.
1511
+ OpenSSL maintains a separate list of TLS 1.3+ ciphers to
1512
+ ciphers for TLS 1.2 and lowers.
1513
+
1514
+ See the OpenSSL manual for more information (e.g.
1515
+ :manpage:`ciphers(1)`).
1516
+
1517
+ :param bytes ciphersuites: An OpenSSL cipher string containing
1518
+ TLS 1.3+ ciphersuites.
1519
+ :return: None
1520
+
1521
+ .. versionadded:: 25.2.0
1522
+ """
1523
+ ciphersuites = _text_to_bytes_and_warn ("ciphersuites" , ciphersuites )
1524
+
1525
+ if not isinstance (ciphersuites , bytes ):
1526
+ raise TypeError ("ciphersuites must be a byte string." )
1527
+
1528
+ _openssl_assert (
1529
+ _lib .SSL_CTX_set_ciphersuites (self ._context , ciphersuites ) == 1
1530
+ )
1531
+
1504
1532
@_require_not_used
1505
1533
def set_client_ca_list (
1506
1534
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