File tree Expand file tree Collapse file tree 3 files changed +53
-0
lines changed Expand file tree Collapse file tree 3 files changed +53
-0
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_tls13_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_tls13_ciphersuites` for that.
1474
+
1472
1475
:param bytes cipher_list: An OpenSSL cipher string.
1473
1476
:return: None
1474
1477
"""
@@ -1501,6 +1504,29 @@ def set_cipher_list(self, cipher_list: bytes) -> None:
1501
1504
],
1502
1505
)
1503
1506
1507
+ @_require_not_used
1508
+ def set_tls13_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
+ if not isinstance (ciphersuites , bytes ):
1524
+ raise TypeError ("ciphersuites must be a byte string." )
1525
+
1526
+ _openssl_assert (
1527
+ _lib .SSL_CTX_set_ciphersuites (self ._context , ciphersuites ) == 1
1528
+ )
1529
+
1504
1530
@_require_not_used
1505
1531
def set_client_ca_list (
1506
1532
self , certificate_authorities : Sequence [X509Name ]
Original file line number Diff line number Diff line change @@ -512,6 +512,20 @@ def test_set_cipher_list(
512
512
513
513
assert "AES128-SHA" in conn .get_cipher_list ()
514
514
515
+ def test_set_tls13_ciphersuites (self , context : Context ) -> None :
516
+ """
517
+ `Context.set_tls13_ciphersuites` accepts both byte and unicode strings
518
+ for naming the ciphers which connections created with the context
519
+ object will be able to choose from.
520
+ """
521
+ context .set_tls13_ciphersuites (b"TLS_AES_128_GCM_SHA256" )
522
+ conn = Connection (context , None )
523
+
524
+ # OpenSSL has different APIs for *setting* TLS <=1.2 and >= 1.3
525
+ # but only one API for retrieving them
526
+ assert "TLS_AES_128_GCM_SHA256" in conn .get_cipher_list ()
527
+ assert "TLS_AES_256_GCM_SHA384" not in conn .get_cipher_list ()
528
+
515
529
def test_set_cipher_list_wrong_type (self , context : Context ) -> None :
516
530
"""
517
531
`Context.set_cipher_list` raises `TypeError` when passed a non-string
You can’t perform that action at this time.
0 commit comments