pyOpenSSL 25.3.0__tar.gz → 26.1.0__tar.gz
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- {pyopenssl-25.3.0 → pyopenssl-26.1.0}/CHANGELOG.rst +25 -2
- {pyopenssl-25.3.0/src/pyOpenSSL.egg-info → pyopenssl-26.1.0}/PKG-INFO +28 -6
- {pyopenssl-25.3.0 → pyopenssl-26.1.0}/doc/backward-compatibility.rst +7 -0
- {pyopenssl-25.3.0 → pyopenssl-26.1.0}/doc/introduction.rst +1 -1
- {pyopenssl-25.3.0 → pyopenssl-26.1.0}/noxfile.py +7 -8
- {pyopenssl-25.3.0 → pyopenssl-26.1.0}/setup.py +2 -3
- {pyopenssl-25.3.0 → pyopenssl-26.1.0}/src/OpenSSL/SSL.py +51 -4
- {pyopenssl-25.3.0 → pyopenssl-26.1.0}/src/OpenSSL/crypto.py +6 -4
- {pyopenssl-25.3.0 → pyopenssl-26.1.0}/src/OpenSSL/version.py +2 -2
- {pyopenssl-25.3.0 → pyopenssl-26.1.0/src/pyOpenSSL.egg-info}/PKG-INFO +28 -6
- {pyopenssl-25.3.0 → pyopenssl-26.1.0}/src/pyOpenSSL.egg-info/requires.txt +1 -1
- {pyopenssl-25.3.0 → pyopenssl-26.1.0}/tests/conftest.py +4 -0
- {pyopenssl-25.3.0 → pyopenssl-26.1.0}/tests/test_crypto.py +68 -80
- {pyopenssl-25.3.0 → pyopenssl-26.1.0}/tests/test_ssl.py +218 -12
- {pyopenssl-25.3.0 → pyopenssl-26.1.0}/tests/test_util.py +1 -1
- {pyopenssl-25.3.0 → pyopenssl-26.1.0}/CODE_OF_CONDUCT.rst +0 -0
- {pyopenssl-25.3.0 → pyopenssl-26.1.0}/CONTRIBUTING.rst +0 -0
- {pyopenssl-25.3.0 → pyopenssl-26.1.0}/INSTALL.rst +0 -0
- {pyopenssl-25.3.0 → pyopenssl-26.1.0}/LICENSE +0 -0
- {pyopenssl-25.3.0 → pyopenssl-26.1.0}/MANIFEST.in +0 -0
- {pyopenssl-25.3.0 → pyopenssl-26.1.0}/README.rst +0 -0
- {pyopenssl-25.3.0 → pyopenssl-26.1.0}/doc/ChangeLog_old.txt +0 -0
- {pyopenssl-25.3.0 → pyopenssl-26.1.0}/doc/Makefile +0 -0
- {pyopenssl-25.3.0 → pyopenssl-26.1.0}/doc/Quotes +0 -0
- {pyopenssl-25.3.0 → pyopenssl-26.1.0}/doc/README +0 -0
- {pyopenssl-25.3.0 → pyopenssl-26.1.0}/doc/api/crypto.rst +0 -0
- {pyopenssl-25.3.0 → pyopenssl-26.1.0}/doc/api/ssl.rst +0 -0
- {pyopenssl-25.3.0 → pyopenssl-26.1.0}/doc/api.rst +0 -0
- {pyopenssl-25.3.0 → pyopenssl-26.1.0}/doc/changelog.rst +0 -0
- {pyopenssl-25.3.0 → pyopenssl-26.1.0}/doc/conf.py +0 -0
- {pyopenssl-25.3.0 → pyopenssl-26.1.0}/doc/images/pyopenssl-brand.png +0 -0
- {pyopenssl-25.3.0 → pyopenssl-26.1.0}/doc/images/pyopenssl-icon.png +0 -0
- {pyopenssl-25.3.0 → pyopenssl-26.1.0}/doc/images/pyopenssl-logo.png +0 -0
- {pyopenssl-25.3.0 → pyopenssl-26.1.0}/doc/images/pyopenssl.svg +0 -0
- {pyopenssl-25.3.0 → pyopenssl-26.1.0}/doc/index.rst +0 -0
- {pyopenssl-25.3.0 → pyopenssl-26.1.0}/doc/install.rst +0 -0
- {pyopenssl-25.3.0 → pyopenssl-26.1.0}/doc/internals.rst +0 -0
- {pyopenssl-25.3.0 → pyopenssl-26.1.0}/doc/make.bat +0 -0
- {pyopenssl-25.3.0 → pyopenssl-26.1.0}/pyproject.toml +0 -0
- {pyopenssl-25.3.0 → pyopenssl-26.1.0}/setup.cfg +0 -0
- {pyopenssl-25.3.0 → pyopenssl-26.1.0}/src/OpenSSL/__init__.py +0 -0
- {pyopenssl-25.3.0 → pyopenssl-26.1.0}/src/OpenSSL/_util.py +0 -0
- {pyopenssl-25.3.0 → pyopenssl-26.1.0}/src/OpenSSL/debug.py +0 -0
- {pyopenssl-25.3.0 → pyopenssl-26.1.0}/src/OpenSSL/py.typed +0 -0
- {pyopenssl-25.3.0 → pyopenssl-26.1.0}/src/OpenSSL/rand.py +0 -0
- {pyopenssl-25.3.0 → pyopenssl-26.1.0}/src/pyOpenSSL.egg-info/SOURCES.txt +0 -0
- {pyopenssl-25.3.0 → pyopenssl-26.1.0}/src/pyOpenSSL.egg-info/dependency_links.txt +0 -0
- {pyopenssl-25.3.0 → pyopenssl-26.1.0}/src/pyOpenSSL.egg-info/top_level.txt +0 -0
- {pyopenssl-25.3.0 → pyopenssl-26.1.0}/tests/__init__.py +0 -0
- {pyopenssl-25.3.0 → pyopenssl-26.1.0}/tests/test_debug.py +0 -0
- {pyopenssl-25.3.0 → pyopenssl-26.1.0}/tests/test_rand.py +0 -0
- {pyopenssl-25.3.0 → pyopenssl-26.1.0}/tests/util.py +0 -0
|
@@ -4,7 +4,7 @@ Changelog
|
|
|
4
4
|
Versions are year-based with a strict backward-compatibility policy.
|
|
5
5
|
The third digit is only for regressions.
|
|
6
6
|
|
|
7
|
-
|
|
7
|
+
26.1.0 (2026-04-24)
|
|
8
8
|
-------------------
|
|
9
9
|
|
|
10
10
|
Backward-incompatible changes:
|
|
@@ -16,6 +16,29 @@ Deprecations:
|
|
|
16
16
|
Changes:
|
|
17
17
|
^^^^^^^^
|
|
18
18
|
|
|
19
|
+
- Maximum supported ``cryptography`` version is now 47.x.
|
|
20
|
+
- Fixed ``X509Name`` field setters to correctly pass the value length to OpenSSL. Previously, values containing NUL bytes would be silently truncated, causing a divergence between the stored ASN.1 value and the value visible from Python. Credit to **BudongJW** for reporting the issue. **CVE-2026-40475**
|
|
21
|
+
|
|
22
|
+
26.0.0 (2026-03-15)
|
|
23
|
+
-------------------
|
|
24
|
+
|
|
25
|
+
Backward-incompatible changes:
|
|
26
|
+
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
|
|
27
|
+
|
|
28
|
+
- Dropped support for Python 3.7.
|
|
29
|
+
- The minimum ``cryptography`` version is now 46.0.0.
|
|
30
|
+
|
|
31
|
+
Deprecations:
|
|
32
|
+
^^^^^^^^^^^^^
|
|
33
|
+
|
|
34
|
+
Changes:
|
|
35
|
+
^^^^^^^^
|
|
36
|
+
|
|
37
|
+
- Added support for using aws-lc instead of OpenSSL.
|
|
38
|
+
- Properly raise an error if a DTLS cookie callback returned a cookie longer than ``DTLS1_COOKIE_LENGTH`` bytes. Previously this would result in a buffer-overflow. Credit to **dark_haxor** for reporting the issue. **CVE-2026-27459**
|
|
39
|
+
- Added ``OpenSSL.SSL.Connection.get_group_name`` to determine which group name was negotiated.
|
|
40
|
+
- ``Context.set_tlsext_servername_callback`` now handles exceptions raised in the callback by calling ``sys.excepthook`` and returning a fatal TLS alert. Previously, exceptions were silently swallowed and the handshake would proceed as if the callback had succeeded. Credit to **Leury Castillo** for reporting this issue. **CVE-2026-27448**
|
|
41
|
+
|
|
19
42
|
25.3.0 (2025-09-16)
|
|
20
43
|
-------------------
|
|
21
44
|
|
|
@@ -100,7 +123,7 @@ Deprecations:
|
|
|
100
123
|
- Deprecated ``add_extensions`` and ``get_extensions`` on ``OpenSSL.crypto.X509Req`` and ``OpenSSL.crypto.X509``. These should have been deprecated at the same time ``X509Extension`` was. Users should use pyca/cryptography's X.509 APIs instead.
|
|
101
124
|
- Deprecated ``OpenSSL.crypto.get_elliptic_curves`` and ``OpenSSL.crypto.get_elliptic_curve``, as well as passing the reult of them to ``OpenSSL.SSL.Context.set_tmp_ecdh``, users should instead pass curves from ``cryptography``.
|
|
102
125
|
- Deprecated passing ``X509`` objects to ``OpenSSL.SSL.Context.use_certificate``, ``OpenSSL.SSL.Connection.use_certificate``, ``OpenSSL.SSL.Context.add_extra_chain_cert``, and ``OpenSSL.SSL.Context.add_client_ca``, users should instead pass ``cryptography.x509.Certificate`` instances. This is in preparation for deprecating pyOpenSSL's ``X509`` entirely.
|
|
103
|
-
- Deprecated passing ``PKey`` objects to ``OpenSSL.SSL.Context.use_privatekey`` and ``OpenSSL.SSL.Connection.use_privatekey``, users should instead pass ``cryptography``
|
|
126
|
+
- Deprecated passing ``PKey`` objects to ``OpenSSL.SSL.Context.use_privatekey`` and ``OpenSSL.SSL.Connection.use_privatekey``, users should instead pass ``cryptography`` private key instances. This is in preparation for deprecating pyOpenSSL's ``PKey`` entirely.
|
|
104
127
|
|
|
105
128
|
Changes:
|
|
106
129
|
^^^^^^^^
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
Metadata-Version: 2.4
|
|
2
2
|
Name: pyOpenSSL
|
|
3
|
-
Version:
|
|
3
|
+
Version: 26.1.0
|
|
4
4
|
Summary: Python wrapper module around the OpenSSL library
|
|
5
5
|
Home-page: https://pyopenssl.org/
|
|
6
6
|
Author: The pyOpenSSL developers
|
|
@@ -14,7 +14,6 @@ Classifier: Operating System :: MacOS :: MacOS X
|
|
|
14
14
|
Classifier: Operating System :: Microsoft :: Windows
|
|
15
15
|
Classifier: Operating System :: POSIX
|
|
16
16
|
Classifier: Programming Language :: Python :: 3
|
|
17
|
-
Classifier: Programming Language :: Python :: 3.7
|
|
18
17
|
Classifier: Programming Language :: Python :: 3.8
|
|
19
18
|
Classifier: Programming Language :: Python :: 3.9
|
|
20
19
|
Classifier: Programming Language :: Python :: 3.10
|
|
@@ -26,9 +25,9 @@ Classifier: Programming Language :: Python :: Implementation :: PyPy
|
|
|
26
25
|
Classifier: Topic :: Security :: Cryptography
|
|
27
26
|
Classifier: Topic :: Software Development :: Libraries :: Python Modules
|
|
28
27
|
Classifier: Topic :: System :: Networking
|
|
29
|
-
Requires-Python: >=3.
|
|
28
|
+
Requires-Python: >=3.8
|
|
30
29
|
License-File: LICENSE
|
|
31
|
-
Requires-Dist: cryptography<
|
|
30
|
+
Requires-Dist: cryptography<48,>=46.0.0
|
|
32
31
|
Requires-Dist: typing-extensions>=4.9; python_version < "3.13" and python_version >= "3.8"
|
|
33
32
|
Provides-Extra: test
|
|
34
33
|
Requires-Dist: pytest-rerunfailures; extra == "test"
|
|
@@ -97,7 +96,7 @@ You can also join ``#pyca`` on ``irc.libera.chat`` to ask questions or get invol
|
|
|
97
96
|
Release Information
|
|
98
97
|
===================
|
|
99
98
|
|
|
100
|
-
|
|
99
|
+
26.1.0 (2026-04-24)
|
|
101
100
|
-------------------
|
|
102
101
|
|
|
103
102
|
Backward-incompatible changes:
|
|
@@ -109,6 +108,29 @@ Deprecations:
|
|
|
109
108
|
Changes:
|
|
110
109
|
^^^^^^^^
|
|
111
110
|
|
|
111
|
+
- Maximum supported ``cryptography`` version is now 47.x.
|
|
112
|
+
- Fixed ``X509Name`` field setters to correctly pass the value length to OpenSSL. Previously, values containing NUL bytes would be silently truncated, causing a divergence between the stored ASN.1 value and the value visible from Python. Credit to **BudongJW** for reporting the issue. **CVE-2026-40475**
|
|
113
|
+
|
|
114
|
+
26.0.0 (2026-03-15)
|
|
115
|
+
-------------------
|
|
116
|
+
|
|
117
|
+
Backward-incompatible changes:
|
|
118
|
+
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
|
|
119
|
+
|
|
120
|
+
- Dropped support for Python 3.7.
|
|
121
|
+
- The minimum ``cryptography`` version is now 46.0.0.
|
|
122
|
+
|
|
123
|
+
Deprecations:
|
|
124
|
+
^^^^^^^^^^^^^
|
|
125
|
+
|
|
126
|
+
Changes:
|
|
127
|
+
^^^^^^^^
|
|
128
|
+
|
|
129
|
+
- Added support for using aws-lc instead of OpenSSL.
|
|
130
|
+
- Properly raise an error if a DTLS cookie callback returned a cookie longer than ``DTLS1_COOKIE_LENGTH`` bytes. Previously this would result in a buffer-overflow. Credit to **dark_haxor** for reporting the issue. **CVE-2026-27459**
|
|
131
|
+
- Added ``OpenSSL.SSL.Connection.get_group_name`` to determine which group name was negotiated.
|
|
132
|
+
- ``Context.set_tlsext_servername_callback`` now handles exceptions raised in the callback by calling ``sys.excepthook`` and returning a fatal TLS alert. Previously, exceptions were silently swallowed and the handshake would proceed as if the callback had succeeded. Credit to **Leury Castillo** for reporting this issue. **CVE-2026-27448**
|
|
133
|
+
|
|
112
134
|
25.3.0 (2025-09-16)
|
|
113
135
|
-------------------
|
|
114
136
|
|
|
@@ -193,7 +215,7 @@ Deprecations:
|
|
|
193
215
|
- Deprecated ``add_extensions`` and ``get_extensions`` on ``OpenSSL.crypto.X509Req`` and ``OpenSSL.crypto.X509``. These should have been deprecated at the same time ``X509Extension`` was. Users should use pyca/cryptography's X.509 APIs instead.
|
|
194
216
|
- Deprecated ``OpenSSL.crypto.get_elliptic_curves`` and ``OpenSSL.crypto.get_elliptic_curve``, as well as passing the reult of them to ``OpenSSL.SSL.Context.set_tmp_ecdh``, users should instead pass curves from ``cryptography``.
|
|
195
217
|
- Deprecated passing ``X509`` objects to ``OpenSSL.SSL.Context.use_certificate``, ``OpenSSL.SSL.Connection.use_certificate``, ``OpenSSL.SSL.Context.add_extra_chain_cert``, and ``OpenSSL.SSL.Context.add_client_ca``, users should instead pass ``cryptography.x509.Certificate`` instances. This is in preparation for deprecating pyOpenSSL's ``X509`` entirely.
|
|
196
|
-
- Deprecated passing ``PKey`` objects to ``OpenSSL.SSL.Context.use_privatekey`` and ``OpenSSL.SSL.Connection.use_privatekey``, users should instead pass ``cryptography``
|
|
218
|
+
- Deprecated passing ``PKey`` objects to ``OpenSSL.SSL.Context.use_privatekey`` and ``OpenSSL.SSL.Connection.use_privatekey``, users should instead pass ``cryptography`` private key instances. This is in preparation for deprecating pyOpenSSL's ``PKey`` entirely.
|
|
197
219
|
|
|
198
220
|
Changes:
|
|
199
221
|
^^^^^^^^
|
|
@@ -9,3 +9,10 @@ If breaking changes are needed do be done, they are:
|
|
|
9
9
|
#. …announced in the :doc:`changelog`.
|
|
10
10
|
#. …the old behavior raises a :exc:`DeprecationWarning` for a year.
|
|
11
11
|
#. …are done with another announcement in the :doc:`changelog`.
|
|
12
|
+
|
|
13
|
+
Versioning Policy
|
|
14
|
+
=================
|
|
15
|
+
|
|
16
|
+
pyOpenSSL follows `CalVer <https://calver.org>`_ in `YY.MINOR.MICRO` format.
|
|
17
|
+
Unlike SemVer, major versions represent the year, and are not indicative of
|
|
18
|
+
breaking changes.
|
|
@@ -14,7 +14,7 @@ Other OpenSSL wrappers for Python at the time were also limited, though in diffe
|
|
|
14
14
|
Later it was maintained by `Jean-Paul Calderone`_ who among other things managed to make pyOpenSSL a pure Python project which the current maintainers are *very* grateful for.
|
|
15
15
|
|
|
16
16
|
Over the time the standard library's ``ssl`` module improved, never reaching the completeness of pyOpenSSL's API coverage.
|
|
17
|
-
pyOpenSSL remains the only choice for full-featured TLS code in Python versions 3.
|
|
17
|
+
pyOpenSSL remains the only choice for full-featured TLS code in Python versions 3.8+ and PyPy_.
|
|
18
18
|
|
|
19
19
|
|
|
20
20
|
Development
|
|
@@ -3,7 +3,7 @@ import nox
|
|
|
3
3
|
nox.options.reuse_existing_virtualenvs = True
|
|
4
4
|
nox.options.default_venv_backend = "uv|virtualenv"
|
|
5
5
|
|
|
6
|
-
MINIMUM_CRYPTOGRAPHY_VERSION = "
|
|
6
|
+
MINIMUM_CRYPTOGRAPHY_VERSION = "46.0.0"
|
|
7
7
|
|
|
8
8
|
|
|
9
9
|
@nox.session
|
|
@@ -28,12 +28,6 @@ def tests(session: nox.Session) -> None:
|
|
|
28
28
|
if "random-order" in session.name:
|
|
29
29
|
random_order = True
|
|
30
30
|
|
|
31
|
-
session.env.update(
|
|
32
|
-
{
|
|
33
|
-
"PIP_NO_BINARY": "" if use_wheel else "cryptography",
|
|
34
|
-
}
|
|
35
|
-
)
|
|
36
|
-
|
|
37
31
|
deps = ["coverage>=4.2"]
|
|
38
32
|
|
|
39
33
|
if cryptography_version == "minimum":
|
|
@@ -42,8 +36,13 @@ def tests(session: nox.Session) -> None:
|
|
|
42
36
|
if random_order:
|
|
43
37
|
deps.append("pytest-randomly")
|
|
44
38
|
|
|
39
|
+
extra_install_args = []
|
|
40
|
+
if not use_wheel:
|
|
41
|
+
extra_install_args.append("--no-binary")
|
|
42
|
+
extra_install_args.append("cryptography")
|
|
43
|
+
|
|
45
44
|
session.install(*deps)
|
|
46
|
-
session.install("-e", ".[test]")
|
|
45
|
+
session.install("-e", ".[test]", *extra_install_args)
|
|
47
46
|
if cryptography_version == "main":
|
|
48
47
|
session.install("git+https://github.com/pyca/cryptography.git")
|
|
49
48
|
|
|
@@ -77,7 +77,6 @@ if __name__ == "__main__":
|
|
|
77
77
|
"Operating System :: Microsoft :: Windows",
|
|
78
78
|
"Operating System :: POSIX",
|
|
79
79
|
"Programming Language :: Python :: 3",
|
|
80
|
-
"Programming Language :: Python :: 3.7",
|
|
81
80
|
"Programming Language :: Python :: 3.8",
|
|
82
81
|
"Programming Language :: Python :: 3.9",
|
|
83
82
|
"Programming Language :: Python :: 3.10",
|
|
@@ -90,11 +89,11 @@ if __name__ == "__main__":
|
|
|
90
89
|
"Topic :: Software Development :: Libraries :: Python Modules",
|
|
91
90
|
"Topic :: System :: Networking",
|
|
92
91
|
],
|
|
93
|
-
python_requires=">=3.
|
|
92
|
+
python_requires=">=3.8",
|
|
94
93
|
packages=find_packages(where="src"),
|
|
95
94
|
package_dir={"": "src"},
|
|
96
95
|
install_requires=[
|
|
97
|
-
"cryptography>=
|
|
96
|
+
"cryptography>=46.0.0,<48",
|
|
98
97
|
(
|
|
99
98
|
"typing-extensions>=4.9; "
|
|
100
99
|
"python_version < '3.13' and python_version >= '3.8'"
|
|
@@ -2,6 +2,7 @@ from __future__ import annotations
|
|
|
2
2
|
|
|
3
3
|
import os
|
|
4
4
|
import socket
|
|
5
|
+
import sys
|
|
5
6
|
import typing
|
|
6
7
|
import warnings
|
|
7
8
|
from collections.abc import Sequence
|
|
@@ -64,7 +65,6 @@ __all__ = [
|
|
|
64
65
|
"OPENSSL_VERSION_NUMBER",
|
|
65
66
|
"OP_ALL",
|
|
66
67
|
"OP_CIPHER_SERVER_PREFERENCE",
|
|
67
|
-
"OP_COOKIE_EXCHANGE",
|
|
68
68
|
"OP_DONT_INSERT_EMPTY_FRAGMENTS",
|
|
69
69
|
"OP_EPHEMERAL_RSA",
|
|
70
70
|
"OP_MICROSOFT_BIG_SSLV3_BUFFER",
|
|
@@ -221,7 +221,11 @@ OP_NETSCAPE_DEMO_CIPHER_CHANGE_BUG: int = (
|
|
|
221
221
|
OP_NO_COMPRESSION: int = _lib.SSL_OP_NO_COMPRESSION
|
|
222
222
|
|
|
223
223
|
OP_NO_QUERY_MTU: int = _lib.SSL_OP_NO_QUERY_MTU
|
|
224
|
-
|
|
224
|
+
try:
|
|
225
|
+
OP_COOKIE_EXCHANGE: int | None = _lib.SSL_OP_COOKIE_EXCHANGE
|
|
226
|
+
__all__.append("OP_COOKIE_EXCHANGE")
|
|
227
|
+
except AttributeError:
|
|
228
|
+
OP_COOKIE_EXCHANGE = None
|
|
225
229
|
OP_NO_TICKET: int = _lib.SSL_OP_NO_TICKET
|
|
226
230
|
|
|
227
231
|
try:
|
|
@@ -716,11 +720,18 @@ class _CookieGenerateCallbackHelper(_CallbackExceptionHelper):
|
|
|
716
720
|
def __init__(self, callback: _CookieGenerateCallback) -> None:
|
|
717
721
|
_CallbackExceptionHelper.__init__(self)
|
|
718
722
|
|
|
723
|
+
max_cookie_len = getattr(_lib, "DTLS1_COOKIE_LENGTH", 255)
|
|
724
|
+
|
|
719
725
|
@wraps(callback)
|
|
720
726
|
def wrapper(ssl, out, outlen): # type: ignore[no-untyped-def]
|
|
721
727
|
try:
|
|
722
728
|
conn = Connection._reverse_mapping[ssl]
|
|
723
729
|
cookie = callback(conn)
|
|
730
|
+
if len(cookie) > max_cookie_len:
|
|
731
|
+
raise ValueError(
|
|
732
|
+
f"Cookie too long (got {len(cookie)} bytes, "
|
|
733
|
+
f"max {max_cookie_len})"
|
|
734
|
+
)
|
|
724
735
|
out[0 : len(cookie)] = cookie
|
|
725
736
|
outlen[0] = len(cookie)
|
|
726
737
|
return 1
|
|
@@ -815,6 +826,16 @@ _requires_keylog = _make_requires(
|
|
|
815
826
|
getattr(_lib, "Cryptography_HAS_KEYLOG", 0), "Key logging not available"
|
|
816
827
|
)
|
|
817
828
|
|
|
829
|
+
_requires_ssl_get0_group_name = _make_requires(
|
|
830
|
+
getattr(_lib, "Cryptography_HAS_SSL_GET0_GROUP_NAME", 0),
|
|
831
|
+
"Getting group name is not supported by the linked OpenSSL version",
|
|
832
|
+
)
|
|
833
|
+
|
|
834
|
+
_requires_ssl_cookie = _make_requires(
|
|
835
|
+
getattr(_lib, "Cryptography_HAS_SSL_COOKIE", 0),
|
|
836
|
+
"DTLS cookie support is not available",
|
|
837
|
+
)
|
|
838
|
+
|
|
818
839
|
|
|
819
840
|
class Session:
|
|
820
841
|
"""
|
|
@@ -1041,7 +1062,7 @@ class Context:
|
|
|
1041
1062
|
binary wheels that cryptography (pyOpenSSL's primary dependency) ships:
|
|
1042
1063
|
|
|
1043
1064
|
* macOS will only load certificates using this method if the user has
|
|
1044
|
-
the ``openssl@
|
|
1065
|
+
the ``openssl@3`` `Homebrew <https://brew.sh>`_ formula installed
|
|
1045
1066
|
in the default location.
|
|
1046
1067
|
* Windows will not work.
|
|
1047
1068
|
* manylinux cryptography wheels will work on most common Linux
|
|
@@ -1747,7 +1768,11 @@ class Context:
|
|
|
1747
1768
|
|
|
1748
1769
|
@wraps(callback)
|
|
1749
1770
|
def wrapper(ssl, alert, arg): # type: ignore[no-untyped-def]
|
|
1750
|
-
|
|
1771
|
+
try:
|
|
1772
|
+
callback(Connection._reverse_mapping[ssl])
|
|
1773
|
+
except Exception:
|
|
1774
|
+
sys.excepthook(*sys.exc_info())
|
|
1775
|
+
return _lib.SSL_TLSEXT_ERR_ALERT_FATAL
|
|
1751
1776
|
return 0
|
|
1752
1777
|
|
|
1753
1778
|
self._tlsext_servername_callback = _ffi.callback(
|
|
@@ -1905,6 +1930,7 @@ class Context:
|
|
|
1905
1930
|
self._set_ocsp_callback(helper, data)
|
|
1906
1931
|
|
|
1907
1932
|
@_require_not_used
|
|
1933
|
+
@_requires_ssl_cookie
|
|
1908
1934
|
def set_cookie_generate_callback(
|
|
1909
1935
|
self, callback: _CookieGenerateCallback
|
|
1910
1936
|
) -> None:
|
|
@@ -1915,6 +1941,7 @@ class Context:
|
|
|
1915
1941
|
)
|
|
1916
1942
|
|
|
1917
1943
|
@_require_not_used
|
|
1944
|
+
@_requires_ssl_cookie
|
|
1918
1945
|
def set_cookie_verify_callback(
|
|
1919
1946
|
self, callback: _CookieVerifyCallback
|
|
1920
1947
|
) -> None:
|
|
@@ -3202,6 +3229,26 @@ class Connection:
|
|
|
3202
3229
|
|
|
3203
3230
|
return _ffi.string(profile.name)
|
|
3204
3231
|
|
|
3232
|
+
@_requires_ssl_get0_group_name
|
|
3233
|
+
def get_group_name(self) -> str | None:
|
|
3234
|
+
"""
|
|
3235
|
+
Get the name of the negotiated group for the key exchange.
|
|
3236
|
+
|
|
3237
|
+
:return: A string giving the group name or :data:`None`.
|
|
3238
|
+
"""
|
|
3239
|
+
# Do not remove this guard.
|
|
3240
|
+
# SSL_get0_group_name crashes with a segfault if called without
|
|
3241
|
+
# an established connection (should return NULL but doesn't).
|
|
3242
|
+
session = _lib.SSL_get_session(self._ssl)
|
|
3243
|
+
if session == _ffi.NULL:
|
|
3244
|
+
return None
|
|
3245
|
+
|
|
3246
|
+
group_name = _lib.SSL_get0_group_name(self._ssl)
|
|
3247
|
+
if group_name == _ffi.NULL:
|
|
3248
|
+
return None
|
|
3249
|
+
|
|
3250
|
+
return _ffi.string(group_name).decode("utf-8")
|
|
3251
|
+
|
|
3205
3252
|
def request_ocsp(self) -> None:
|
|
3206
3253
|
"""
|
|
3207
3254
|
Called to request that the server sends stapled OCSP data, if
|
|
@@ -651,7 +651,7 @@ class X509Name:
|
|
|
651
651
|
value = value.encode("utf-8")
|
|
652
652
|
|
|
653
653
|
add_result = _lib.X509_NAME_add_entry_by_NID(
|
|
654
|
-
self._name, nid, _lib.MBSTRING_UTF8, value,
|
|
654
|
+
self._name, nid, _lib.MBSTRING_UTF8, value, len(value), -1, 0
|
|
655
655
|
)
|
|
656
656
|
if not add_result:
|
|
657
657
|
_raise_current_error()
|
|
@@ -885,9 +885,11 @@ class X509Extension:
|
|
|
885
885
|
_lib.GENERAL_NAME_print(bio, name)
|
|
886
886
|
parts.append(_bio_to_string(bio).decode("utf-8"))
|
|
887
887
|
else:
|
|
888
|
-
|
|
889
|
-
|
|
890
|
-
|
|
888
|
+
asn1_string = _ffi.cast("ASN1_STRING*", name.d.ia5)
|
|
889
|
+
value = _ffi.buffer(
|
|
890
|
+
_lib.ASN1_STRING_get0_data(asn1_string),
|
|
891
|
+
_lib.ASN1_STRING_length(asn1_string),
|
|
892
|
+
)[:].decode("utf-8")
|
|
891
893
|
parts.append(label + ":" + value)
|
|
892
894
|
return ", ".join(parts)
|
|
893
895
|
|
|
@@ -17,7 +17,7 @@ __all__ = [
|
|
|
17
17
|
"__version__",
|
|
18
18
|
]
|
|
19
19
|
|
|
20
|
-
__version__ = "
|
|
20
|
+
__version__ = "26.1.0"
|
|
21
21
|
|
|
22
22
|
__title__ = "pyOpenSSL"
|
|
23
23
|
__uri__ = "https://pyopenssl.org/"
|
|
@@ -25,4 +25,4 @@ __summary__ = "Python wrapper module around the OpenSSL library"
|
|
|
25
25
|
__author__ = "The pyOpenSSL developers"
|
|
26
26
|
__email__ = "cryptography-dev@python.org"
|
|
27
27
|
__license__ = "Apache License, Version 2.0"
|
|
28
|
-
__copyright__ = f"Copyright 2001-
|
|
28
|
+
__copyright__ = f"Copyright 2001-2026 {__author__}"
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
Metadata-Version: 2.4
|
|
2
2
|
Name: pyOpenSSL
|
|
3
|
-
Version:
|
|
3
|
+
Version: 26.1.0
|
|
4
4
|
Summary: Python wrapper module around the OpenSSL library
|
|
5
5
|
Home-page: https://pyopenssl.org/
|
|
6
6
|
Author: The pyOpenSSL developers
|
|
@@ -14,7 +14,6 @@ Classifier: Operating System :: MacOS :: MacOS X
|
|
|
14
14
|
Classifier: Operating System :: Microsoft :: Windows
|
|
15
15
|
Classifier: Operating System :: POSIX
|
|
16
16
|
Classifier: Programming Language :: Python :: 3
|
|
17
|
-
Classifier: Programming Language :: Python :: 3.7
|
|
18
17
|
Classifier: Programming Language :: Python :: 3.8
|
|
19
18
|
Classifier: Programming Language :: Python :: 3.9
|
|
20
19
|
Classifier: Programming Language :: Python :: 3.10
|
|
@@ -26,9 +25,9 @@ Classifier: Programming Language :: Python :: Implementation :: PyPy
|
|
|
26
25
|
Classifier: Topic :: Security :: Cryptography
|
|
27
26
|
Classifier: Topic :: Software Development :: Libraries :: Python Modules
|
|
28
27
|
Classifier: Topic :: System :: Networking
|
|
29
|
-
Requires-Python: >=3.
|
|
28
|
+
Requires-Python: >=3.8
|
|
30
29
|
License-File: LICENSE
|
|
31
|
-
Requires-Dist: cryptography<
|
|
30
|
+
Requires-Dist: cryptography<48,>=46.0.0
|
|
32
31
|
Requires-Dist: typing-extensions>=4.9; python_version < "3.13" and python_version >= "3.8"
|
|
33
32
|
Provides-Extra: test
|
|
34
33
|
Requires-Dist: pytest-rerunfailures; extra == "test"
|
|
@@ -97,7 +96,7 @@ You can also join ``#pyca`` on ``irc.libera.chat`` to ask questions or get invol
|
|
|
97
96
|
Release Information
|
|
98
97
|
===================
|
|
99
98
|
|
|
100
|
-
|
|
99
|
+
26.1.0 (2026-04-24)
|
|
101
100
|
-------------------
|
|
102
101
|
|
|
103
102
|
Backward-incompatible changes:
|
|
@@ -109,6 +108,29 @@ Deprecations:
|
|
|
109
108
|
Changes:
|
|
110
109
|
^^^^^^^^
|
|
111
110
|
|
|
111
|
+
- Maximum supported ``cryptography`` version is now 47.x.
|
|
112
|
+
- Fixed ``X509Name`` field setters to correctly pass the value length to OpenSSL. Previously, values containing NUL bytes would be silently truncated, causing a divergence between the stored ASN.1 value and the value visible from Python. Credit to **BudongJW** for reporting the issue. **CVE-2026-40475**
|
|
113
|
+
|
|
114
|
+
26.0.0 (2026-03-15)
|
|
115
|
+
-------------------
|
|
116
|
+
|
|
117
|
+
Backward-incompatible changes:
|
|
118
|
+
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
|
|
119
|
+
|
|
120
|
+
- Dropped support for Python 3.7.
|
|
121
|
+
- The minimum ``cryptography`` version is now 46.0.0.
|
|
122
|
+
|
|
123
|
+
Deprecations:
|
|
124
|
+
^^^^^^^^^^^^^
|
|
125
|
+
|
|
126
|
+
Changes:
|
|
127
|
+
^^^^^^^^
|
|
128
|
+
|
|
129
|
+
- Added support for using aws-lc instead of OpenSSL.
|
|
130
|
+
- Properly raise an error if a DTLS cookie callback returned a cookie longer than ``DTLS1_COOKIE_LENGTH`` bytes. Previously this would result in a buffer-overflow. Credit to **dark_haxor** for reporting the issue. **CVE-2026-27459**
|
|
131
|
+
- Added ``OpenSSL.SSL.Connection.get_group_name`` to determine which group name was negotiated.
|
|
132
|
+
- ``Context.set_tlsext_servername_callback`` now handles exceptions raised in the callback by calling ``sys.excepthook`` and returning a fatal TLS alert. Previously, exceptions were silently swallowed and the handshake would proceed as if the callback had succeeded. Credit to **Leury Castillo** for reporting this issue. **CVE-2026-27448**
|
|
133
|
+
|
|
112
134
|
25.3.0 (2025-09-16)
|
|
113
135
|
-------------------
|
|
114
136
|
|
|
@@ -193,7 +215,7 @@ Deprecations:
|
|
|
193
215
|
- Deprecated ``add_extensions`` and ``get_extensions`` on ``OpenSSL.crypto.X509Req`` and ``OpenSSL.crypto.X509``. These should have been deprecated at the same time ``X509Extension`` was. Users should use pyca/cryptography's X.509 APIs instead.
|
|
194
216
|
- Deprecated ``OpenSSL.crypto.get_elliptic_curves`` and ``OpenSSL.crypto.get_elliptic_curve``, as well as passing the reult of them to ``OpenSSL.SSL.Context.set_tmp_ecdh``, users should instead pass curves from ``cryptography``.
|
|
195
217
|
- Deprecated passing ``X509`` objects to ``OpenSSL.SSL.Context.use_certificate``, ``OpenSSL.SSL.Connection.use_certificate``, ``OpenSSL.SSL.Context.add_extra_chain_cert``, and ``OpenSSL.SSL.Context.add_client_ca``, users should instead pass ``cryptography.x509.Certificate`` instances. This is in preparation for deprecating pyOpenSSL's ``X509`` entirely.
|
|
196
|
-
- Deprecated passing ``PKey`` objects to ``OpenSSL.SSL.Context.use_privatekey`` and ``OpenSSL.SSL.Connection.use_privatekey``, users should instead pass ``cryptography``
|
|
218
|
+
- Deprecated passing ``PKey`` objects to ``OpenSSL.SSL.Context.use_privatekey`` and ``OpenSSL.SSL.Connection.use_privatekey``, users should instead pass ``cryptography`` private key instances. This is in preparation for deprecating pyOpenSSL's ``PKey`` entirely.
|
|
197
219
|
|
|
198
220
|
Changes:
|
|
199
221
|
^^^^^^^^
|
|
@@ -58,6 +58,7 @@ from OpenSSL.crypto import (
|
|
|
58
58
|
load_publickey,
|
|
59
59
|
)
|
|
60
60
|
|
|
61
|
+
from . import conftest
|
|
61
62
|
from .util import (
|
|
62
63
|
NON_ASCII,
|
|
63
64
|
)
|
|
@@ -71,7 +72,7 @@ def utcnow() -> datetime:
|
|
|
71
72
|
return datetime.now(timezone.utc).replace(tzinfo=None)
|
|
72
73
|
|
|
73
74
|
|
|
74
|
-
GOOD_CIPHER = "
|
|
75
|
+
GOOD_CIPHER = "aes-256-cbc"
|
|
75
76
|
BAD_CIPHER = "zippers"
|
|
76
77
|
|
|
77
78
|
GOOD_DIGEST = "SHA256"
|
|
@@ -555,60 +556,6 @@ ywIDAQAB
|
|
|
555
556
|
-----END PUBLIC KEY-----
|
|
556
557
|
"""
|
|
557
558
|
|
|
558
|
-
crlData = b"""\
|
|
559
|
-
-----BEGIN X509 CRL-----
|
|
560
|
-
MIIBWzCBxTANBgkqhkiG9w0BAQQFADBYMQswCQYDVQQGEwJVUzELMAkGA1UECBMC
|
|
561
|
-
SUwxEDAOBgNVBAcTB0NoaWNhZ28xEDAOBgNVBAoTB1Rlc3RpbmcxGDAWBgNVBAMT
|
|
562
|
-
D1Rlc3RpbmcgUm9vdCBDQRcNMDkwNzI2MDQzNDU2WhcNMTIwOTI3MDI0MTUyWjA8
|
|
563
|
-
MBUCAgOrGA8yMDA5MDcyNTIzMzQ1NlowIwICAQAYDzIwMDkwNzI1MjMzNDU2WjAM
|
|
564
|
-
MAoGA1UdFQQDCgEEMA0GCSqGSIb3DQEBBAUAA4GBAEBt7xTs2htdD3d4ErrcGAw1
|
|
565
|
-
4dKcVnIWTutoI7xxen26Wwvh8VCsT7i/UeP+rBl9rC/kfjWjzQk3/zleaarGTpBT
|
|
566
|
-
0yp4HXRFFoRhhSE/hP+eteaPXRgrsNRLHe9ZDd69wmh7J1wMDb0m81RG7kqcbsid
|
|
567
|
-
vrzEeLDRiiPl92dyyWmu
|
|
568
|
-
-----END X509 CRL-----
|
|
569
|
-
"""
|
|
570
|
-
|
|
571
|
-
# The signature on this CRL is invalid.
|
|
572
|
-
crlDataUnsupportedExtension = b"""\
|
|
573
|
-
-----BEGIN X509 CRL-----
|
|
574
|
-
MIIGRzCCBS8CAQEwDQYJKoZIhvcNAQELBQAwJzELMAkGA1UEBhMCVVMxGDAWBgNV
|
|
575
|
-
BAMMD2NyeXB0b2dyYXBoeS5pbxgPMjAxNTAxMDEwMDAwMDBaGA8yMDE2MDEwMTAw
|
|
576
|
-
MDAwMFowggTOMBQCAQAYDzIwMTUwMTAxMDAwMDAwWjByAgEBGA8yMDE1MDEwMTAw
|
|
577
|
-
MDAwMFowXDAYBgNVHRgEERgPMjAxNTAxMDEwMDAwMDBaMDQGA1UdHQQtMCukKTAn
|
|
578
|
-
MQswCQYDVQQGEwJVUzEYMBYGA1UEAwwPY3J5cHRvZ3JhcGh5LmlvMAoGA1UdFQQD
|
|
579
|
-
CgEAMHICAQIYDzIwMTUwMTAxMDAwMDAwWjBcMBgGA1UdGAQRGA8yMDE1MDEwMTAw
|
|
580
|
-
MDAwMFowNAYDVR0dBC0wK6QpMCcxCzAJBgNVBAYTAlVTMRgwFgYDVQQDDA9jcnlw
|
|
581
|
-
dG9ncmFwaHkuaW8wCgYDVR0VBAMKAQEwcgIBAxgPMjAxNTAxMDEwMDAwMDBaMFww
|
|
582
|
-
GAYDVR0YBBEYDzIwMTUwMTAxMDAwMDAwWjA0BgNVHR0ELTArpCkwJzELMAkGA1UE
|
|
583
|
-
BhMCVVMxGDAWBgNVBAMMD2NyeXB0b2dyYXBoeS5pbzAKBgNVHRUEAwoBAjByAgEE
|
|
584
|
-
GA8yMDE1MDEwMTAwMDAwMFowXDAYBgNVHRgEERgPMjAxNTAxMDEwMDAwMDBaMDQG
|
|
585
|
-
A1UdHQQtMCukKTAnMQswCQYDVQQGEwJVUzEYMBYGA1UEAwwPY3J5cHRvZ3JhcGh5
|
|
586
|
-
LmlvMAoGA1UdFQQDCgEDMHICAQUYDzIwMTUwMTAxMDAwMDAwWjBcMBgGA1UdGAQR
|
|
587
|
-
GA8yMDE1MDEwMTAwMDAwMFowNAYDVR0dBC0wK6QpMCcxCzAJBgNVBAYTAlVTMRgw
|
|
588
|
-
FgYDVQQDDA9jcnlwdG9ncmFwaHkuaW8wCgYDVR0VBAMKAQQwcgIBBhgPMjAxNTAx
|
|
589
|
-
MDEwMDAwMDBaMFwwGAYDVR0YBBEYDzIwMTUwMTAxMDAwMDAwWjA0BgNVHR0ELTAr
|
|
590
|
-
pCkwJzELMAkGA1UEBhMCVVMxGDAWBgNVBAMMD2NyeXB0b2dyYXBoeS5pbzAKBgNV
|
|
591
|
-
HRUEAwoBBTByAgEHGA8yMDE1MDEwMTAwMDAwMFowXDAYBgNVHRgEERgPMjAxNTAx
|
|
592
|
-
MDEwMDAwMDBaMDQGA1UdHQQtMCukKTAnMQswCQYDVQQGEwJVUzEYMBYGA1UEAwwP
|
|
593
|
-
Y3J5cHRvZ3JhcGh5LmlvMAoGA1UdFQQDCgEGMHICAQgYDzIwMTUwMTAxMDAwMDAw
|
|
594
|
-
WjBcMBgGA1UdGAQRGA8yMDE1MDEwMTAwMDAwMFowNAYDVR0dBC0wK6QpMCcxCzAJ
|
|
595
|
-
BgNVBAYTAlVTMRgwFgYDVQQDDA9jcnlwdG9ncmFwaHkuaW8wCgYDVR0VBAMKAQgw
|
|
596
|
-
cgIBCRgPMjAxNTAxMDEwMDAwMDBaMFwwGAYDVR0YBBEYDzIwMTUwMTAxMDAwMDAw
|
|
597
|
-
WjA0BgNVHR0ELTArpCkwJzELMAkGA1UEBhMCVVMxGDAWBgNVBAMMD2NyeXB0b2dy
|
|
598
|
-
YXBoeS5pbzAKBgNVHRUEAwoBCTByAgEKGA8yMDE1MDEwMTAwMDAwMFowXDAYBgNV
|
|
599
|
-
HRgEERgPMjAxNTAxMDEwMDAwMDBaMDQGA1UdHQQtMCukKTAnMQswCQYDVQQGEwJV
|
|
600
|
-
UzEYMBYGA1UEAwwPY3J5cHRvZ3JhcGh5LmlvMAoGA1UdFQQDCgEKMC4CAQsYDzIw
|
|
601
|
-
MTUwMTAxMDAwMDAwWjAYMAoGA1UdFQQDCgEBMAoGAyoDBAQDCgEAMA0GCSqGSIb3
|
|
602
|
-
DQEBCwUAA4IBAQBTaloHlPaCZzYee8LxkWej5meiqxQVNWFoVdjesroa+f1FRrH+
|
|
603
|
-
drRU60Nq97KCKf7f9GNN/J3ZIlQmYhmuDqh12f+XLpotoj1ZRfBz2hjFCkJlv+2c
|
|
604
|
-
oWWGNHgA70ndFoVtcmX088SYpX8E3ARATivS4q2h9WlwV6rO93mhg3HGIe3JpcK4
|
|
605
|
-
7BcW6Poi/ut/zsDOkVbI00SqaujRpdmdCTht82MH3ztjyDkI9KYaD/YEweKSrWOz
|
|
606
|
-
SdEILd164bfBeLuplVI+xpmTEMVNpXBlSXl7+xIw9Vk7p7Q1Pa3k/SvhOldYCm6y
|
|
607
|
-
C1xAg/AAq6w78yzYt18j5Mj0s6eeHi1YpHKw
|
|
608
|
-
-----END X509 CRL-----
|
|
609
|
-
"""
|
|
610
|
-
|
|
611
|
-
|
|
612
559
|
# A broken RSA private key which can be used to test the error path through
|
|
613
560
|
# PKey.check.
|
|
614
561
|
inconsistentPrivateKeyPEM = b"""-----BEGIN RSA PRIVATE KEY-----
|
|
@@ -1077,8 +1024,22 @@ class TestPKey:
|
|
|
1077
1024
|
[
|
|
1078
1025
|
(dsa_private_key_pem, dsa.DSAPrivateKey),
|
|
1079
1026
|
(ec_private_key_pem, ec.EllipticCurvePrivateKey),
|
|
1080
|
-
(
|
|
1081
|
-
|
|
1027
|
+
pytest.param(
|
|
1028
|
+
ed25519_private_key_pem,
|
|
1029
|
+
ed25519.Ed25519PrivateKey,
|
|
1030
|
+
marks=pytest.mark.skipif(
|
|
1031
|
+
conftest.is_awslc,
|
|
1032
|
+
reason="aws-lc doesn't support Ed25519 serialization",
|
|
1033
|
+
),
|
|
1034
|
+
),
|
|
1035
|
+
pytest.param(
|
|
1036
|
+
ed448_private_key_pem,
|
|
1037
|
+
ed448.Ed448PrivateKey,
|
|
1038
|
+
marks=pytest.mark.skipif(
|
|
1039
|
+
conftest.is_awslc,
|
|
1040
|
+
reason="aws-lc doesn't support Ed448",
|
|
1041
|
+
),
|
|
1042
|
+
),
|
|
1082
1043
|
(rsa_private_key_pem, rsa.RSAPrivateKey),
|
|
1083
1044
|
],
|
|
1084
1045
|
)
|
|
@@ -1131,8 +1092,22 @@ class TestPKey:
|
|
|
1131
1092
|
[
|
|
1132
1093
|
(dsa_public_key_pem, dsa.DSAPublicKey),
|
|
1133
1094
|
(ec_public_key_pem, ec.EllipticCurvePublicKey),
|
|
1134
|
-
(
|
|
1135
|
-
|
|
1095
|
+
pytest.param(
|
|
1096
|
+
ed25519_public_key_pem,
|
|
1097
|
+
ed25519.Ed25519PublicKey,
|
|
1098
|
+
marks=pytest.mark.skipif(
|
|
1099
|
+
conftest.is_awslc,
|
|
1100
|
+
reason="aws-lc doesn't support Ed25519 serialization",
|
|
1101
|
+
),
|
|
1102
|
+
),
|
|
1103
|
+
pytest.param(
|
|
1104
|
+
ed448_public_key_pem,
|
|
1105
|
+
ed448.Ed448PublicKey,
|
|
1106
|
+
marks=pytest.mark.skipif(
|
|
1107
|
+
conftest.is_awslc,
|
|
1108
|
+
reason="aws-lc doesn't support Ed448",
|
|
1109
|
+
),
|
|
1110
|
+
),
|
|
1136
1111
|
(rsa_public_key_pem, rsa.RSAPublicKey),
|
|
1137
1112
|
],
|
|
1138
1113
|
)
|
|
@@ -1428,6 +1403,14 @@ class TestX509Name:
|
|
|
1428
1403
|
name.emailAddress = "quux@example.com"
|
|
1429
1404
|
assert copy.emailAddress == "bar@example.com"
|
|
1430
1405
|
|
|
1406
|
+
def test_null_bytes_preserved(self) -> None:
|
|
1407
|
+
"""
|
|
1408
|
+
Null bytes in X509Name field values are round-tripped correctly.
|
|
1409
|
+
"""
|
|
1410
|
+
name = x509_name()
|
|
1411
|
+
name.CN = "a\x00b"
|
|
1412
|
+
assert name.CN == "a\x00b"
|
|
1413
|
+
|
|
1431
1414
|
def test_repr(self) -> None:
|
|
1432
1415
|
"""
|
|
1433
1416
|
`repr` passed an `X509Name` instance should return a string containing
|
|
@@ -1876,6 +1859,8 @@ class TestX509:
|
|
|
1876
1859
|
key = PKey()
|
|
1877
1860
|
key.generate_key(TYPE_RSA, 2048)
|
|
1878
1861
|
cert.set_pubkey(key)
|
|
1862
|
+
cert.gmtime_adj_notBefore(0)
|
|
1863
|
+
cert.gmtime_adj_notAfter(24 * 60 * 60)
|
|
1879
1864
|
cert.sign(key, GOOD_DIGEST)
|
|
1880
1865
|
|
|
1881
1866
|
def test_construction(self) -> None:
|
|
@@ -1944,20 +1929,21 @@ class TestX509:
|
|
|
1944
1929
|
set(certificate, when)
|
|
1945
1930
|
assert get(certificate) == when
|
|
1946
1931
|
|
|
1947
|
-
|
|
1948
|
-
|
|
1949
|
-
|
|
1950
|
-
|
|
1951
|
-
|
|
1952
|
-
|
|
1953
|
-
|
|
1954
|
-
|
|
1955
|
-
|
|
1956
|
-
|
|
1957
|
-
|
|
1932
|
+
if not conftest.is_awslc:
|
|
1933
|
+
# A plus two hours and thirty minutes offset
|
|
1934
|
+
when = b"20040203040506+0530"
|
|
1935
|
+
set(certificate, when)
|
|
1936
|
+
assert get(certificate) == when
|
|
1937
|
+
|
|
1938
|
+
# A minus one hour fifteen minutes offset
|
|
1939
|
+
when = b"20040203040506-0115"
|
|
1940
|
+
set(certificate, when)
|
|
1941
|
+
assert (
|
|
1942
|
+
get(
|
|
1943
|
+
certificate,
|
|
1944
|
+
)
|
|
1945
|
+
== when
|
|
1958
1946
|
)
|
|
1959
|
-
== when
|
|
1960
|
-
)
|
|
1961
1947
|
|
|
1962
1948
|
# An invalid string results in a ValueError
|
|
1963
1949
|
with pytest.raises(ValueError):
|
|
@@ -2017,16 +2003,17 @@ class TestX509:
|
|
|
2017
2003
|
current time plus the number of seconds passed in.
|
|
2018
2004
|
"""
|
|
2019
2005
|
cert = load_certificate(FILETYPE_PEM, self.pemData)
|
|
2020
|
-
|
|
2021
|
-
|
|
2022
|
-
)
|
|
2006
|
+
utc_now = utcnow().replace(microsecond=0)
|
|
2007
|
+
# -1 second tolerance for clock adjustments
|
|
2008
|
+
not_before_min = utc_now + timedelta(seconds=99)
|
|
2023
2009
|
cert.gmtime_adj_notBefore(100)
|
|
2024
2010
|
not_before_str = cert.get_notBefore()
|
|
2025
2011
|
assert not_before_str is not None
|
|
2026
2012
|
not_before = datetime.strptime(
|
|
2027
2013
|
not_before_str.decode(), "%Y%m%d%H%M%SZ"
|
|
2028
2014
|
)
|
|
2029
|
-
|
|
2015
|
+
# +1 second tolerance for clock adjustments
|
|
2016
|
+
not_before_max = utc_now + timedelta(seconds=101)
|
|
2030
2017
|
assert not_before_min <= not_before <= not_before_max
|
|
2031
2018
|
|
|
2032
2019
|
def test_gmtime_adj_notAfter_wrong_args(self) -> None:
|
|
@@ -2045,14 +2032,15 @@ class TestX509:
|
|
|
2045
2032
|
to be the current time plus the number of seconds passed in.
|
|
2046
2033
|
"""
|
|
2047
2034
|
cert = load_certificate(FILETYPE_PEM, self.pemData)
|
|
2048
|
-
|
|
2049
|
-
|
|
2050
|
-
)
|
|
2035
|
+
utc_now = utcnow().replace(microsecond=0)
|
|
2036
|
+
# -1 second tolerance for clock adjustments
|
|
2037
|
+
not_after_min = utc_now + timedelta(seconds=99)
|
|
2051
2038
|
cert.gmtime_adj_notAfter(100)
|
|
2052
2039
|
not_after_str = cert.get_notAfter()
|
|
2053
2040
|
assert not_after_str is not None
|
|
2054
2041
|
not_after = datetime.strptime(not_after_str.decode(), "%Y%m%d%H%M%SZ")
|
|
2055
|
-
|
|
2042
|
+
# +1 second tolerance for clock adjustments
|
|
2043
|
+
not_after_max = utc_now + timedelta(seconds=101)
|
|
2056
2044
|
assert not_after_min <= not_after <= not_after_max
|
|
2057
2045
|
|
|
2058
2046
|
def test_has_expired(self) -> None:
|
|
@@ -37,6 +37,7 @@ from socket import (
|
|
|
37
37
|
SOL_SOCKET,
|
|
38
38
|
gaierror,
|
|
39
39
|
socket,
|
|
40
|
+
socketpair,
|
|
40
41
|
)
|
|
41
42
|
from sys import getfilesystemencoding, platform
|
|
42
43
|
from weakref import ref
|
|
@@ -66,7 +67,6 @@ from OpenSSL.crypto import (
|
|
|
66
67
|
)
|
|
67
68
|
from OpenSSL.SSL import (
|
|
68
69
|
DTLS_METHOD,
|
|
69
|
-
MODE_RELEASE_BUFFERS,
|
|
70
70
|
NO_OVERLAPPING_PROTOCOLS,
|
|
71
71
|
OP_COOKIE_EXCHANGE,
|
|
72
72
|
OP_NO_COMPRESSION,
|
|
@@ -131,6 +131,7 @@ from OpenSSL.SSL import (
|
|
|
131
131
|
_NoOverlappingProtocols,
|
|
132
132
|
)
|
|
133
133
|
|
|
134
|
+
from . import conftest
|
|
134
135
|
from .test_crypto import (
|
|
135
136
|
client_cert_pem,
|
|
136
137
|
client_key_pem,
|
|
@@ -642,6 +643,12 @@ class TestContext:
|
|
|
642
643
|
"",
|
|
643
644
|
"no cipher match",
|
|
644
645
|
),
|
|
646
|
+
# aws-lc
|
|
647
|
+
(
|
|
648
|
+
"SSL routines",
|
|
649
|
+
"OPENSSL_internal",
|
|
650
|
+
"NO_CIPHER_MATCH",
|
|
651
|
+
),
|
|
645
652
|
]
|
|
646
653
|
|
|
647
654
|
def test_load_client_ca(self, context: Context, ca_file: bytes) -> None:
|
|
@@ -670,7 +677,8 @@ class TestContext:
|
|
|
670
677
|
"""
|
|
671
678
|
Passing the path as unicode raises a warning but works.
|
|
672
679
|
"""
|
|
673
|
-
pytest.deprecated_call(
|
|
680
|
+
with pytest.deprecated_call():
|
|
681
|
+
context.load_client_ca(ca_file.decode("ascii")) # type: ignore[arg-type]
|
|
674
682
|
|
|
675
683
|
def test_set_session_id(self, context: Context) -> None:
|
|
676
684
|
"""
|
|
@@ -698,6 +706,12 @@ class TestContext:
|
|
|
698
706
|
"",
|
|
699
707
|
"ssl session id context too long",
|
|
700
708
|
),
|
|
709
|
+
# aws-lc
|
|
710
|
+
(
|
|
711
|
+
"SSL routines",
|
|
712
|
+
"OPENSSL_internal",
|
|
713
|
+
"SSL_SESSION_ID_CONTEXT_TOO_LONG",
|
|
714
|
+
),
|
|
701
715
|
]
|
|
702
716
|
|
|
703
717
|
def test_set_session_id_unicode(self, context: Context) -> None:
|
|
@@ -705,7 +719,8 @@ class TestContext:
|
|
|
705
719
|
`Context.set_session_id` raises a warning if a unicode string is
|
|
706
720
|
passed.
|
|
707
721
|
"""
|
|
708
|
-
pytest.deprecated_call(
|
|
722
|
+
with pytest.deprecated_call():
|
|
723
|
+
context.set_session_id("abc") # type: ignore[arg-type]
|
|
709
724
|
|
|
710
725
|
def test_method(self) -> None:
|
|
711
726
|
"""
|
|
@@ -919,7 +934,8 @@ class TestContext:
|
|
|
919
934
|
newly set mode.
|
|
920
935
|
"""
|
|
921
936
|
context = Context(SSLv23_METHOD)
|
|
922
|
-
|
|
937
|
+
mode = _lib.SSL_MODE_ENABLE_PARTIAL_WRITE
|
|
938
|
+
assert mode & context.set_mode(mode)
|
|
923
939
|
|
|
924
940
|
def test_set_timeout_wrong_args(self) -> None:
|
|
925
941
|
"""
|
|
@@ -966,7 +982,7 @@ class TestContext:
|
|
|
966
982
|
"""
|
|
967
983
|
key = PKey()
|
|
968
984
|
key.generate_key(TYPE_RSA, 1024)
|
|
969
|
-
pem = dump_privatekey(FILETYPE_PEM, key, "
|
|
985
|
+
pem = dump_privatekey(FILETYPE_PEM, key, "aes-256-cbc", passphrase)
|
|
970
986
|
with open(tmpfile, "w") as fObj:
|
|
971
987
|
fObj.write(pem.decode("ascii"))
|
|
972
988
|
return tmpfile
|
|
@@ -1160,7 +1176,7 @@ class TestContext:
|
|
|
1160
1176
|
client_context = Context(TLS_METHOD)
|
|
1161
1177
|
client_context.set_max_proto_version(low_version)
|
|
1162
1178
|
|
|
1163
|
-
with pytest.raises(Error, match="unsupported
|
|
1179
|
+
with pytest.raises(Error, match=r"(?i)unsupported.protocol"):
|
|
1164
1180
|
self._handshake_test(server_context, client_context)
|
|
1165
1181
|
|
|
1166
1182
|
client_context = Context(TLS_METHOD)
|
|
@@ -1629,7 +1645,9 @@ class TestContext:
|
|
|
1629
1645
|
if mode == SSL.VERIFY_PEER:
|
|
1630
1646
|
with pytest.raises(Exception) as exc:
|
|
1631
1647
|
self._handshake_test(serverContext, clientContext)
|
|
1632
|
-
assert "certificate verify failed" in str(
|
|
1648
|
+
assert "certificate verify failed" in str(
|
|
1649
|
+
exc.value
|
|
1650
|
+
) or "CERTIFICATE_VERIFY_FAILED" in str(exc.value)
|
|
1633
1651
|
else:
|
|
1634
1652
|
self._handshake_test(serverContext, clientContext)
|
|
1635
1653
|
|
|
@@ -1858,9 +1876,27 @@ class TestContext:
|
|
|
1858
1876
|
with pytest.deprecated_call():
|
|
1859
1877
|
context.set_tmp_ecdh(curve)
|
|
1860
1878
|
|
|
1879
|
+
awslc_unsupported_curves = {
|
|
1880
|
+
"BRAINPOOLP256R1",
|
|
1881
|
+
"BRAINPOOLP384R1",
|
|
1882
|
+
"BRAINPOOLP512R1",
|
|
1883
|
+
"SECP192R1",
|
|
1884
|
+
"SECT163K1",
|
|
1885
|
+
"SECT163R2",
|
|
1886
|
+
"SECT233K1",
|
|
1887
|
+
"SECT233R1",
|
|
1888
|
+
"SECT283K1",
|
|
1889
|
+
"SECT283R1",
|
|
1890
|
+
"SECT409K1",
|
|
1891
|
+
"SECT409R1",
|
|
1892
|
+
"SECT571K1",
|
|
1893
|
+
"SECT571R1",
|
|
1894
|
+
}
|
|
1861
1895
|
for name in dir(ec.EllipticCurveOID):
|
|
1862
1896
|
if name.startswith("_"):
|
|
1863
1897
|
continue
|
|
1898
|
+
if conftest.is_awslc and name in awslc_unsupported_curves:
|
|
1899
|
+
continue
|
|
1864
1900
|
oid = getattr(ec.EllipticCurveOID, name)
|
|
1865
1901
|
cryptography_curve = ec.get_curve_for_oid(oid)
|
|
1866
1902
|
context.set_tmp_ecdh(cryptography_curve())
|
|
@@ -2031,6 +2067,56 @@ class TestServerNameCallback:
|
|
|
2031
2067
|
|
|
2032
2068
|
assert args == [(server, b"foo1.example.com")]
|
|
2033
2069
|
|
|
2070
|
+
def test_servername_callback_exception(
|
|
2071
|
+
self, monkeypatch: pytest.MonkeyPatch
|
|
2072
|
+
) -> None:
|
|
2073
|
+
"""
|
|
2074
|
+
When the callback passed to `Context.set_tlsext_servername_callback`
|
|
2075
|
+
raises an exception, ``sys.excepthook`` is called with the exception
|
|
2076
|
+
and the handshake fails with an ``Error``.
|
|
2077
|
+
"""
|
|
2078
|
+
exc = TypeError("server name callback failed")
|
|
2079
|
+
|
|
2080
|
+
def servername(conn: Connection) -> None:
|
|
2081
|
+
raise exc
|
|
2082
|
+
|
|
2083
|
+
excepthook_calls: list[
|
|
2084
|
+
tuple[type[BaseException], BaseException, object]
|
|
2085
|
+
] = []
|
|
2086
|
+
|
|
2087
|
+
def custom_excepthook(
|
|
2088
|
+
exc_type: type[BaseException],
|
|
2089
|
+
exc_value: BaseException,
|
|
2090
|
+
exc_tb: object,
|
|
2091
|
+
) -> None:
|
|
2092
|
+
excepthook_calls.append((exc_type, exc_value, exc_tb))
|
|
2093
|
+
|
|
2094
|
+
context = Context(SSLv23_METHOD)
|
|
2095
|
+
context.set_tlsext_servername_callback(servername)
|
|
2096
|
+
|
|
2097
|
+
# Necessary to actually accept the connection
|
|
2098
|
+
context.use_privatekey(load_privatekey(FILETYPE_PEM, server_key_pem))
|
|
2099
|
+
context.use_certificate(
|
|
2100
|
+
load_certificate(FILETYPE_PEM, server_cert_pem)
|
|
2101
|
+
)
|
|
2102
|
+
|
|
2103
|
+
# Do a little connection to trigger the logic
|
|
2104
|
+
server = Connection(context, None)
|
|
2105
|
+
server.set_accept_state()
|
|
2106
|
+
|
|
2107
|
+
client = Connection(Context(SSLv23_METHOD), None)
|
|
2108
|
+
client.set_connect_state()
|
|
2109
|
+
client.set_tlsext_host_name(b"foo1.example.com")
|
|
2110
|
+
|
|
2111
|
+
monkeypatch.setattr(sys, "excepthook", custom_excepthook)
|
|
2112
|
+
with pytest.raises(Error):
|
|
2113
|
+
interact_in_memory(server, client)
|
|
2114
|
+
|
|
2115
|
+
assert len(excepthook_calls) == 1
|
|
2116
|
+
assert excepthook_calls[0][0] is TypeError
|
|
2117
|
+
assert excepthook_calls[0][1] is exc
|
|
2118
|
+
assert excepthook_calls[0][2] is not None
|
|
2119
|
+
|
|
2034
2120
|
|
|
2035
2121
|
class TestApplicationLayerProtoNegotiation:
|
|
2036
2122
|
"""
|
|
@@ -2696,10 +2782,12 @@ class TestConnection:
|
|
|
2696
2782
|
assert tls_server.get_state_string() in [
|
|
2697
2783
|
b"before/accept initialization",
|
|
2698
2784
|
b"before SSL initialization",
|
|
2785
|
+
b"TLS server start_accept",
|
|
2699
2786
|
]
|
|
2700
2787
|
assert tls_client.get_state_string() in [
|
|
2701
2788
|
b"before/connect initialization",
|
|
2702
2789
|
b"before SSL initialization",
|
|
2790
|
+
b"TLS client start_connect",
|
|
2703
2791
|
]
|
|
2704
2792
|
|
|
2705
2793
|
def test_app_data(self) -> None:
|
|
@@ -3070,7 +3158,14 @@ class TestConnection:
|
|
|
3070
3158
|
`OpenSSL.SSL.WantWriteError` if writing to the connection's BIO
|
|
3071
3159
|
fail indicating a should-write state.
|
|
3072
3160
|
"""
|
|
3073
|
-
|
|
3161
|
+
# Use Unix domain sockets rather than TCP loopback. On macOS,
|
|
3162
|
+
# TCP loopback aggressively auto-tunes buffer sizes and drains
|
|
3163
|
+
# the send buffer into the peer's receive buffer nearly
|
|
3164
|
+
# instantly, so the send buffer won't stay full long enough
|
|
3165
|
+
# for do_handshake() to observe it.
|
|
3166
|
+
client_socket, peer = socketpair()
|
|
3167
|
+
client_socket.setblocking(False)
|
|
3168
|
+
peer.setblocking(False)
|
|
3074
3169
|
# Fill up the client's send buffer so Connection won't be able to write
|
|
3075
3170
|
# anything. Start by sending larger chunks (Windows Socket I/O is slow)
|
|
3076
3171
|
# and continue by writing a single byte at a time so we can be sure we
|
|
@@ -3169,9 +3264,10 @@ class TestConnection:
|
|
|
3169
3264
|
return False # Retry succeeded
|
|
3170
3265
|
except SSL.Error as e:
|
|
3171
3266
|
reason = get_ssl_error_reason(e)
|
|
3172
|
-
assert reason
|
|
3173
|
-
|
|
3174
|
-
|
|
3267
|
+
assert reason in (
|
|
3268
|
+
"bad write retry",
|
|
3269
|
+
"BAD_WRITE_RETRY",
|
|
3270
|
+
), f"Retry failed with unexpected SSL error: {e!r}({reason})."
|
|
3175
3271
|
return True # Bad write retry
|
|
3176
3272
|
|
|
3177
3273
|
def _shutdown_connections(
|
|
@@ -3437,6 +3533,54 @@ class TestConnection:
|
|
|
3437
3533
|
|
|
3438
3534
|
assert server_protocol_version == client_protocol_version
|
|
3439
3535
|
|
|
3536
|
+
@pytest.mark.skipif(
|
|
3537
|
+
not getattr(_lib, "Cryptography_HAS_SSL_GET0_GROUP_NAME", None),
|
|
3538
|
+
reason="SSL_get0_group_name unavailable",
|
|
3539
|
+
)
|
|
3540
|
+
def test_get_group_name_before_connect(self) -> None:
|
|
3541
|
+
"""
|
|
3542
|
+
`Connection.get_group_name()` returns `None` if no connection
|
|
3543
|
+
has been established.
|
|
3544
|
+
"""
|
|
3545
|
+
ctx = Context(TLS_METHOD)
|
|
3546
|
+
conn = Connection(ctx, None)
|
|
3547
|
+
assert conn.get_group_name() is None
|
|
3548
|
+
|
|
3549
|
+
@pytest.mark.skipif(
|
|
3550
|
+
not getattr(_lib, "Cryptography_HAS_SSL_GET0_GROUP_NAME", None),
|
|
3551
|
+
reason="SSL_get0_group_name unavailable",
|
|
3552
|
+
)
|
|
3553
|
+
def test_group_name_null_case(
|
|
3554
|
+
self, monkeypatch: pytest.MonkeyPatch
|
|
3555
|
+
) -> None:
|
|
3556
|
+
"""
|
|
3557
|
+
`Connection.get_group_name()` returns `None` when SSL_get0_group_name
|
|
3558
|
+
returns NULL.
|
|
3559
|
+
"""
|
|
3560
|
+
monkeypatch.setattr(_lib, "SSL_get0_group_name", lambda ssl: _ffi.NULL)
|
|
3561
|
+
|
|
3562
|
+
server, client = loopback()
|
|
3563
|
+
assert server.get_group_name() is None
|
|
3564
|
+
assert client.get_group_name() is None
|
|
3565
|
+
|
|
3566
|
+
@pytest.mark.skipif(
|
|
3567
|
+
not getattr(_lib, "Cryptography_HAS_SSL_GET0_GROUP_NAME", None),
|
|
3568
|
+
reason="SSL_get0_group_name unavailable",
|
|
3569
|
+
)
|
|
3570
|
+
def test_get_group_name(self) -> None:
|
|
3571
|
+
"""
|
|
3572
|
+
`Connection.get_group_name()` returns a string giving the
|
|
3573
|
+
name of the connection's negotiated key exchange group.
|
|
3574
|
+
"""
|
|
3575
|
+
server, client = loopback()
|
|
3576
|
+
server_group_name = server.get_group_name()
|
|
3577
|
+
client_group_name = client.get_group_name()
|
|
3578
|
+
|
|
3579
|
+
assert isinstance(server_group_name, str)
|
|
3580
|
+
assert isinstance(client_group_name, str)
|
|
3581
|
+
|
|
3582
|
+
assert server_group_name == client_group_name
|
|
3583
|
+
|
|
3440
3584
|
def test_wantReadError(self) -> None:
|
|
3441
3585
|
"""
|
|
3442
3586
|
`Connection.bio_read` raises `OpenSSL.SSL.WantReadError` if there are
|
|
@@ -3837,6 +3981,10 @@ class TestConnectionRenegotiate:
|
|
|
3837
3981
|
connection = Connection(Context(SSLv23_METHOD), None)
|
|
3838
3982
|
assert connection.total_renegotiations() == 0
|
|
3839
3983
|
|
|
3984
|
+
@pytest.mark.skipif(
|
|
3985
|
+
conftest.is_awslc,
|
|
3986
|
+
reason="aws-lc doesn't support renegotiation",
|
|
3987
|
+
)
|
|
3840
3988
|
def test_renegotiate(self) -> None:
|
|
3841
3989
|
"""
|
|
3842
3990
|
Go through a complete renegotiation cycle.
|
|
@@ -3930,6 +4078,10 @@ class TestConstants:
|
|
|
3930
4078
|
"OP_NO_COMPRESSION unavailable - OpenSSL version may be too old"
|
|
3931
4079
|
),
|
|
3932
4080
|
)
|
|
4081
|
+
@pytest.mark.skipif(
|
|
4082
|
+
conftest.is_awslc,
|
|
4083
|
+
reason="aws-lc defines OP_NO_COMPRESSION as 0",
|
|
4084
|
+
)
|
|
3933
4085
|
def test_op_no_compression(self) -> None:
|
|
3934
4086
|
"""
|
|
3935
4087
|
The value of `OpenSSL.SSL.OP_NO_COMPRESSION` is 0x20000, the
|
|
@@ -4534,7 +4686,11 @@ class TestOCSP:
|
|
|
4534
4686
|
Tests for PyOpenSSL's OCSP stapling support.
|
|
4535
4687
|
"""
|
|
4536
4688
|
|
|
4537
|
-
|
|
4689
|
+
# Minimal valid DER-encoded OCSPResponse with status "unauthorized"
|
|
4690
|
+
# (SEQUENCE { ENUMERATED 6 }). Required by OpenSSL 4.0+, which parses
|
|
4691
|
+
# the bytes via d2i_OCSP_RESPONSE before stapling and silently drops
|
|
4692
|
+
# unparseable input.
|
|
4693
|
+
sample_ocsp_data = b"\x30\x03\x0a\x01\x06"
|
|
4538
4694
|
|
|
4539
4695
|
def _client_connection(
|
|
4540
4696
|
self,
|
|
@@ -4992,12 +5148,62 @@ class TestDTLS:
|
|
|
4992
5148
|
c.set_ciphertext_mtu(500)
|
|
4993
5149
|
assert 0 < c.get_cleartext_mtu() < 500
|
|
4994
5150
|
|
|
5151
|
+
@pytest.mark.skipif(
|
|
5152
|
+
OP_COOKIE_EXCHANGE is None,
|
|
5153
|
+
reason="DTLS cookie exchange not supported",
|
|
5154
|
+
)
|
|
4995
5155
|
def test_it_works_at_all(self) -> None:
|
|
4996
5156
|
self._test_handshake_and_data(srtp_profile=None)
|
|
4997
5157
|
|
|
5158
|
+
@pytest.mark.skipif(
|
|
5159
|
+
OP_COOKIE_EXCHANGE is None,
|
|
5160
|
+
reason="DTLS cookie exchange not supported",
|
|
5161
|
+
)
|
|
4998
5162
|
def test_it_works_with_srtp(self) -> None:
|
|
4999
5163
|
self._test_handshake_and_data(srtp_profile=b"SRTP_AES128_CM_SHA1_80")
|
|
5000
5164
|
|
|
5165
|
+
@pytest.mark.skipif(
|
|
5166
|
+
OP_COOKIE_EXCHANGE is None,
|
|
5167
|
+
reason="DTLS cookie exchange not supported",
|
|
5168
|
+
)
|
|
5169
|
+
def test_cookie_generate_too_long(self) -> None:
|
|
5170
|
+
s_ctx = Context(DTLS_METHOD)
|
|
5171
|
+
|
|
5172
|
+
def generate_cookie(ssl: Connection) -> bytes:
|
|
5173
|
+
return b"\x00" * 256
|
|
5174
|
+
|
|
5175
|
+
def verify_cookie(ssl: Connection, cookie: bytes) -> bool:
|
|
5176
|
+
return True
|
|
5177
|
+
|
|
5178
|
+
s_ctx.set_cookie_generate_callback(generate_cookie)
|
|
5179
|
+
s_ctx.set_cookie_verify_callback(verify_cookie)
|
|
5180
|
+
s_ctx.use_privatekey(load_privatekey(FILETYPE_PEM, server_key_pem))
|
|
5181
|
+
s_ctx.use_certificate(load_certificate(FILETYPE_PEM, server_cert_pem))
|
|
5182
|
+
s_ctx.set_options(OP_NO_QUERY_MTU)
|
|
5183
|
+
s = Connection(s_ctx)
|
|
5184
|
+
s.set_accept_state()
|
|
5185
|
+
|
|
5186
|
+
c_ctx = Context(DTLS_METHOD)
|
|
5187
|
+
c_ctx.set_options(OP_NO_QUERY_MTU)
|
|
5188
|
+
c = Connection(c_ctx)
|
|
5189
|
+
c.set_connect_state()
|
|
5190
|
+
|
|
5191
|
+
c.set_ciphertext_mtu(1500)
|
|
5192
|
+
s.set_ciphertext_mtu(1500)
|
|
5193
|
+
|
|
5194
|
+
# Client sends ClientHello
|
|
5195
|
+
try:
|
|
5196
|
+
c.do_handshake()
|
|
5197
|
+
except SSL.WantReadError:
|
|
5198
|
+
pass
|
|
5199
|
+
chunk = c.bio_read(self.LARGE_BUFFER)
|
|
5200
|
+
s.bio_write(chunk)
|
|
5201
|
+
|
|
5202
|
+
# Server tries DTLSv1_listen, which triggers cookie generation.
|
|
5203
|
+
# The oversized cookie should raise ValueError.
|
|
5204
|
+
with pytest.raises(ValueError, match="Cookie too long"):
|
|
5205
|
+
s.DTLSv1_listen()
|
|
5206
|
+
|
|
5001
5207
|
def test_timeout(self, monkeypatch: pytest.MonkeyPatch) -> None:
|
|
5002
5208
|
c_ctx = Context(DTLS_METHOD)
|
|
5003
5209
|
c = Connection(c_ctx)
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|