pyOpenSSL 26.3.0__tar.gz → 26.5.1__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-26.3.0 → pyopenssl-26.5.1}/CHANGELOG.rst +53 -0
- {pyopenssl-26.3.0 → pyopenssl-26.5.1}/PKG-INFO +57 -4
- {pyopenssl-26.3.0 → pyopenssl-26.5.1}/setup.py +2 -2
- {pyopenssl-26.3.0 → pyopenssl-26.5.1}/src/OpenSSL/SSL.py +55 -75
- {pyopenssl-26.3.0 → pyopenssl-26.5.1}/src/OpenSSL/crypto.py +31 -12
- {pyopenssl-26.3.0 → pyopenssl-26.5.1}/src/OpenSSL/version.py +2 -2
- {pyopenssl-26.3.0 → pyopenssl-26.5.1}/src/pyOpenSSL.egg-info/PKG-INFO +57 -4
- {pyopenssl-26.3.0 → pyopenssl-26.5.1}/src/pyOpenSSL.egg-info/requires.txt +1 -1
- {pyopenssl-26.3.0 → pyopenssl-26.5.1}/tests/test_crypto.py +18 -7
- {pyopenssl-26.3.0 → pyopenssl-26.5.1}/tests/test_ssl.py +75 -2
- {pyopenssl-26.3.0 → pyopenssl-26.5.1}/CODE_OF_CONDUCT.rst +0 -0
- {pyopenssl-26.3.0 → pyopenssl-26.5.1}/CONTRIBUTING.rst +0 -0
- {pyopenssl-26.3.0 → pyopenssl-26.5.1}/INSTALL.rst +0 -0
- {pyopenssl-26.3.0 → pyopenssl-26.5.1}/LICENSE +0 -0
- {pyopenssl-26.3.0 → pyopenssl-26.5.1}/MANIFEST.in +0 -0
- {pyopenssl-26.3.0 → pyopenssl-26.5.1}/README.rst +0 -0
- {pyopenssl-26.3.0 → pyopenssl-26.5.1}/doc/ChangeLog_old.txt +0 -0
- {pyopenssl-26.3.0 → pyopenssl-26.5.1}/doc/Makefile +0 -0
- {pyopenssl-26.3.0 → pyopenssl-26.5.1}/doc/Quotes +0 -0
- {pyopenssl-26.3.0 → pyopenssl-26.5.1}/doc/README +0 -0
- {pyopenssl-26.3.0 → pyopenssl-26.5.1}/doc/api/crypto.rst +0 -0
- {pyopenssl-26.3.0 → pyopenssl-26.5.1}/doc/api/ssl.rst +0 -0
- {pyopenssl-26.3.0 → pyopenssl-26.5.1}/doc/api.rst +0 -0
- {pyopenssl-26.3.0 → pyopenssl-26.5.1}/doc/backward-compatibility.rst +0 -0
- {pyopenssl-26.3.0 → pyopenssl-26.5.1}/doc/changelog.rst +0 -0
- {pyopenssl-26.3.0 → pyopenssl-26.5.1}/doc/conf.py +0 -0
- {pyopenssl-26.3.0 → pyopenssl-26.5.1}/doc/images/pyopenssl-brand.png +0 -0
- {pyopenssl-26.3.0 → pyopenssl-26.5.1}/doc/images/pyopenssl-icon.png +0 -0
- {pyopenssl-26.3.0 → pyopenssl-26.5.1}/doc/images/pyopenssl-logo.png +0 -0
- {pyopenssl-26.3.0 → pyopenssl-26.5.1}/doc/images/pyopenssl.svg +0 -0
- {pyopenssl-26.3.0 → pyopenssl-26.5.1}/doc/index.rst +0 -0
- {pyopenssl-26.3.0 → pyopenssl-26.5.1}/doc/install.rst +0 -0
- {pyopenssl-26.3.0 → pyopenssl-26.5.1}/doc/internals.rst +0 -0
- {pyopenssl-26.3.0 → pyopenssl-26.5.1}/doc/introduction.rst +0 -0
- {pyopenssl-26.3.0 → pyopenssl-26.5.1}/doc/make.bat +0 -0
- {pyopenssl-26.3.0 → pyopenssl-26.5.1}/noxfile.py +0 -0
- {pyopenssl-26.3.0 → pyopenssl-26.5.1}/pyproject.toml +0 -0
- {pyopenssl-26.3.0 → pyopenssl-26.5.1}/setup.cfg +0 -0
- {pyopenssl-26.3.0 → pyopenssl-26.5.1}/src/OpenSSL/__init__.py +0 -0
- {pyopenssl-26.3.0 → pyopenssl-26.5.1}/src/OpenSSL/_util.py +0 -0
- {pyopenssl-26.3.0 → pyopenssl-26.5.1}/src/OpenSSL/debug.py +0 -0
- {pyopenssl-26.3.0 → pyopenssl-26.5.1}/src/OpenSSL/py.typed +0 -0
- {pyopenssl-26.3.0 → pyopenssl-26.5.1}/src/OpenSSL/rand.py +0 -0
- {pyopenssl-26.3.0 → pyopenssl-26.5.1}/src/pyOpenSSL.egg-info/SOURCES.txt +0 -0
- {pyopenssl-26.3.0 → pyopenssl-26.5.1}/src/pyOpenSSL.egg-info/dependency_links.txt +0 -0
- {pyopenssl-26.3.0 → pyopenssl-26.5.1}/src/pyOpenSSL.egg-info/top_level.txt +0 -0
- {pyopenssl-26.3.0 → pyopenssl-26.5.1}/tests/__init__.py +0 -0
- {pyopenssl-26.3.0 → pyopenssl-26.5.1}/tests/conftest.py +0 -0
- {pyopenssl-26.3.0 → pyopenssl-26.5.1}/tests/test_debug.py +0 -0
- {pyopenssl-26.3.0 → pyopenssl-26.5.1}/tests/test_rand.py +0 -0
- {pyopenssl-26.3.0 → pyopenssl-26.5.1}/tests/test_util.py +0 -0
- {pyopenssl-26.3.0 → pyopenssl-26.5.1}/tests/util.py +0 -0
|
@@ -4,6 +4,59 @@ 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
|
+
26.5.1 (2026-12-02)
|
|
8
|
+
-------------------
|
|
9
|
+
|
|
10
|
+
Backward-incompatible changes:
|
|
11
|
+
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
|
|
12
|
+
|
|
13
|
+
Deprecations:
|
|
14
|
+
^^^^^^^^^^^^^
|
|
15
|
+
|
|
16
|
+
Changes:
|
|
17
|
+
^^^^^^^^
|
|
18
|
+
|
|
19
|
+
- Fixed invalid markup in the changelog that prevented 26.5.0 from being uploaded to PyPI. There are no other changes from 26.5.0.
|
|
20
|
+
|
|
21
|
+
|
|
22
|
+
26.5.0 (2026-12-02)
|
|
23
|
+
-------------------
|
|
24
|
+
|
|
25
|
+
Backward-incompatible changes:
|
|
26
|
+
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
|
|
27
|
+
|
|
28
|
+
- ``OpenSSL.crypto.X509.set_serial_number()`` now raises ``ValueError`` for a negative serial number, which
|
|
29
|
+
`RFC 5280 section 4.1.2.2 <https://datatracker.ietf.org/doc/html/rfc5280#section-4.1.2.2>`_ does not permit.
|
|
30
|
+
Passing one previously crashed the interpreter.
|
|
31
|
+
[`#1534 <https://github.com/pyca/pyopenssl/pull/1534>`_]
|
|
32
|
+
|
|
33
|
+
Deprecations:
|
|
34
|
+
^^^^^^^^^^^^^
|
|
35
|
+
|
|
36
|
+
Changes:
|
|
37
|
+
^^^^^^^^
|
|
38
|
+
|
|
39
|
+
- Fixed a race in which an exception raised by a verify, ALPN selection, OCSP, or DTLS cookie callback for one ``Connection`` could be raised on an unrelated ``Connection`` created from the same ``Context`` and used concurrently from another thread. Exceptions from these callbacks are now tracked per ``Connection``. Discovered and reported by SecDim Security Research.
|
|
40
|
+
- Fixed exceptions raised by a verify callback registered with ``Connection.set_verify`` being swallowed instead of being propagated to the caller.
|
|
41
|
+
- ``Connection.master_key()`` now returns ``None`` for TLS 1.3 connections, which have no master secret, instead of raising ``OpenSSL.SSL.Error``.
|
|
42
|
+
- Maximum supported ``cryptography`` version is now 51.x.
|
|
43
|
+
|
|
44
|
+
|
|
45
|
+
26.4.0 (2026-08-01)
|
|
46
|
+
-------------------
|
|
47
|
+
|
|
48
|
+
Backward-incompatible changes:
|
|
49
|
+
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
|
|
50
|
+
|
|
51
|
+
Deprecations:
|
|
52
|
+
^^^^^^^^^^^^^
|
|
53
|
+
|
|
54
|
+
Changes:
|
|
55
|
+
^^^^^^^^
|
|
56
|
+
|
|
57
|
+
- Maximum supported ``cryptography`` version is now 50.x.
|
|
58
|
+
|
|
59
|
+
|
|
7
60
|
26.3.0 (2026-06-12)
|
|
8
61
|
-------------------
|
|
9
62
|
|
|
@@ -1,15 +1,14 @@
|
|
|
1
1
|
Metadata-Version: 2.4
|
|
2
2
|
Name: pyOpenSSL
|
|
3
|
-
Version: 26.
|
|
3
|
+
Version: 26.5.1
|
|
4
4
|
Summary: Python wrapper module around the OpenSSL library
|
|
5
5
|
Home-page: https://pyopenssl.org/
|
|
6
6
|
Author: The pyOpenSSL developers
|
|
7
7
|
Author-email: cryptography-dev@python.org
|
|
8
|
-
License: Apache
|
|
8
|
+
License: Apache-2.0
|
|
9
9
|
Project-URL: Source, https://github.com/pyca/pyopenssl
|
|
10
10
|
Classifier: Development Status :: 6 - Mature
|
|
11
11
|
Classifier: Intended Audience :: Developers
|
|
12
|
-
Classifier: License :: OSI Approved :: Apache Software License
|
|
13
12
|
Classifier: Operating System :: MacOS :: MacOS X
|
|
14
13
|
Classifier: Operating System :: Microsoft :: Windows
|
|
15
14
|
Classifier: Operating System :: POSIX
|
|
@@ -19,6 +18,7 @@ Classifier: Programming Language :: Python :: 3.10
|
|
|
19
18
|
Classifier: Programming Language :: Python :: 3.11
|
|
20
19
|
Classifier: Programming Language :: Python :: 3.12
|
|
21
20
|
Classifier: Programming Language :: Python :: 3.13
|
|
21
|
+
Classifier: Programming Language :: Python :: 3.14
|
|
22
22
|
Classifier: Programming Language :: Python :: Implementation :: CPython
|
|
23
23
|
Classifier: Programming Language :: Python :: Implementation :: PyPy
|
|
24
24
|
Classifier: Topic :: Security :: Cryptography
|
|
@@ -26,7 +26,7 @@ Classifier: Topic :: Software Development :: Libraries :: Python Modules
|
|
|
26
26
|
Classifier: Topic :: System :: Networking
|
|
27
27
|
Requires-Python: >=3.9
|
|
28
28
|
License-File: LICENSE
|
|
29
|
-
Requires-Dist: cryptography<
|
|
29
|
+
Requires-Dist: cryptography<52,>=49.0.0
|
|
30
30
|
Requires-Dist: typing-extensions>=4.9; python_version < "3.13"
|
|
31
31
|
Provides-Extra: test
|
|
32
32
|
Requires-Dist: pytest-rerunfailures; extra == "test"
|
|
@@ -95,6 +95,59 @@ You can also join ``#pyca`` on ``irc.libera.chat`` to ask questions or get invol
|
|
|
95
95
|
Release Information
|
|
96
96
|
===================
|
|
97
97
|
|
|
98
|
+
26.5.1 (2026-12-02)
|
|
99
|
+
-------------------
|
|
100
|
+
|
|
101
|
+
Backward-incompatible changes:
|
|
102
|
+
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
|
|
103
|
+
|
|
104
|
+
Deprecations:
|
|
105
|
+
^^^^^^^^^^^^^
|
|
106
|
+
|
|
107
|
+
Changes:
|
|
108
|
+
^^^^^^^^
|
|
109
|
+
|
|
110
|
+
- Fixed invalid markup in the changelog that prevented 26.5.0 from being uploaded to PyPI. There are no other changes from 26.5.0.
|
|
111
|
+
|
|
112
|
+
|
|
113
|
+
26.5.0 (2026-12-02)
|
|
114
|
+
-------------------
|
|
115
|
+
|
|
116
|
+
Backward-incompatible changes:
|
|
117
|
+
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
|
|
118
|
+
|
|
119
|
+
- ``OpenSSL.crypto.X509.set_serial_number()`` now raises ``ValueError`` for a negative serial number, which
|
|
120
|
+
`RFC 5280 section 4.1.2.2 <https://datatracker.ietf.org/doc/html/rfc5280#section-4.1.2.2>`_ does not permit.
|
|
121
|
+
Passing one previously crashed the interpreter.
|
|
122
|
+
[`#1534 <https://github.com/pyca/pyopenssl/pull/1534>`_]
|
|
123
|
+
|
|
124
|
+
Deprecations:
|
|
125
|
+
^^^^^^^^^^^^^
|
|
126
|
+
|
|
127
|
+
Changes:
|
|
128
|
+
^^^^^^^^
|
|
129
|
+
|
|
130
|
+
- Fixed a race in which an exception raised by a verify, ALPN selection, OCSP, or DTLS cookie callback for one ``Connection`` could be raised on an unrelated ``Connection`` created from the same ``Context`` and used concurrently from another thread. Exceptions from these callbacks are now tracked per ``Connection``. Discovered and reported by SecDim Security Research.
|
|
131
|
+
- Fixed exceptions raised by a verify callback registered with ``Connection.set_verify`` being swallowed instead of being propagated to the caller.
|
|
132
|
+
- ``Connection.master_key()`` now returns ``None`` for TLS 1.3 connections, which have no master secret, instead of raising ``OpenSSL.SSL.Error``.
|
|
133
|
+
- Maximum supported ``cryptography`` version is now 51.x.
|
|
134
|
+
|
|
135
|
+
|
|
136
|
+
26.4.0 (2026-08-01)
|
|
137
|
+
-------------------
|
|
138
|
+
|
|
139
|
+
Backward-incompatible changes:
|
|
140
|
+
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
|
|
141
|
+
|
|
142
|
+
Deprecations:
|
|
143
|
+
^^^^^^^^^^^^^
|
|
144
|
+
|
|
145
|
+
Changes:
|
|
146
|
+
^^^^^^^^
|
|
147
|
+
|
|
148
|
+
- Maximum supported ``cryptography`` version is now 50.x.
|
|
149
|
+
|
|
150
|
+
|
|
98
151
|
26.3.0 (2026-06-12)
|
|
99
152
|
-------------------
|
|
100
153
|
|
|
@@ -72,7 +72,6 @@ if __name__ == "__main__":
|
|
|
72
72
|
classifiers=[
|
|
73
73
|
"Development Status :: 6 - Mature",
|
|
74
74
|
"Intended Audience :: Developers",
|
|
75
|
-
"License :: OSI Approved :: Apache Software License",
|
|
76
75
|
"Operating System :: MacOS :: MacOS X",
|
|
77
76
|
"Operating System :: Microsoft :: Windows",
|
|
78
77
|
"Operating System :: POSIX",
|
|
@@ -82,6 +81,7 @@ if __name__ == "__main__":
|
|
|
82
81
|
"Programming Language :: Python :: 3.11",
|
|
83
82
|
"Programming Language :: Python :: 3.12",
|
|
84
83
|
"Programming Language :: Python :: 3.13",
|
|
84
|
+
"Programming Language :: Python :: 3.14",
|
|
85
85
|
"Programming Language :: Python :: Implementation :: CPython",
|
|
86
86
|
"Programming Language :: Python :: Implementation :: PyPy",
|
|
87
87
|
"Topic :: Security :: Cryptography",
|
|
@@ -92,7 +92,7 @@ if __name__ == "__main__":
|
|
|
92
92
|
packages=find_packages(where="src"),
|
|
93
93
|
package_dir={"": "src"},
|
|
94
94
|
install_requires=[
|
|
95
|
-
"cryptography>=49.0.0,<
|
|
95
|
+
"cryptography>=49.0.0,<52",
|
|
96
96
|
"typing-extensions>=4.9; python_version < '3.13'",
|
|
97
97
|
],
|
|
98
98
|
extras_require={
|
|
@@ -466,43 +466,13 @@ class SysCallError(Error):
|
|
|
466
466
|
pass
|
|
467
467
|
|
|
468
468
|
|
|
469
|
-
class
|
|
470
|
-
"""
|
|
471
|
-
A base class for wrapper classes that allow for intelligent exception
|
|
472
|
-
handling in OpenSSL callbacks.
|
|
473
|
-
|
|
474
|
-
:ivar list _problems: Any exceptions that occurred while executing in a
|
|
475
|
-
context where they could not be raised in the normal way. Typically
|
|
476
|
-
this is because OpenSSL has called into some Python code and requires a
|
|
477
|
-
return value. The exceptions are saved to be raised later when it is
|
|
478
|
-
possible to do so.
|
|
479
|
-
"""
|
|
480
|
-
|
|
481
|
-
def __init__(self) -> None:
|
|
482
|
-
self._problems: list[Exception] = []
|
|
483
|
-
|
|
484
|
-
def raise_if_problem(self) -> None:
|
|
485
|
-
"""
|
|
486
|
-
Raise an exception from the OpenSSL error queue or that was previously
|
|
487
|
-
captured whe running a callback.
|
|
488
|
-
"""
|
|
489
|
-
if self._problems:
|
|
490
|
-
try:
|
|
491
|
-
_raise_current_error()
|
|
492
|
-
except Error:
|
|
493
|
-
pass
|
|
494
|
-
raise self._problems.pop(0)
|
|
495
|
-
|
|
496
|
-
|
|
497
|
-
class _VerifyHelper(_CallbackExceptionHelper):
|
|
469
|
+
class _VerifyHelper:
|
|
498
470
|
"""
|
|
499
471
|
Wrap a callback such that it can be used as a certificate verification
|
|
500
472
|
callback.
|
|
501
473
|
"""
|
|
502
474
|
|
|
503
475
|
def __init__(self, callback: _VerifyCallback) -> None:
|
|
504
|
-
_CallbackExceptionHelper.__init__(self)
|
|
505
|
-
|
|
506
476
|
@wraps(callback)
|
|
507
477
|
def wrapper(ok, store_ctx): # type: ignore[no-untyped-def]
|
|
508
478
|
x509 = _lib.X509_STORE_CTX_get_current_cert(store_ctx)
|
|
@@ -520,7 +490,7 @@ class _VerifyHelper(_CallbackExceptionHelper):
|
|
|
520
490
|
connection, cert, error_number, error_depth, ok
|
|
521
491
|
)
|
|
522
492
|
except Exception as e:
|
|
523
|
-
|
|
493
|
+
connection._callback_problems.append(e)
|
|
524
494
|
return 0
|
|
525
495
|
else:
|
|
526
496
|
if result:
|
|
@@ -534,19 +504,16 @@ class _VerifyHelper(_CallbackExceptionHelper):
|
|
|
534
504
|
)
|
|
535
505
|
|
|
536
506
|
|
|
537
|
-
class _ALPNSelectHelper
|
|
507
|
+
class _ALPNSelectHelper:
|
|
538
508
|
"""
|
|
539
509
|
Wrap a callback such that it can be used as an ALPN selection callback.
|
|
540
510
|
"""
|
|
541
511
|
|
|
542
512
|
def __init__(self, callback: _ALPNSelectCallback) -> None:
|
|
543
|
-
_CallbackExceptionHelper.__init__(self)
|
|
544
|
-
|
|
545
513
|
@wraps(callback)
|
|
546
514
|
def wrapper(ssl, out, outlen, in_, inlen, arg): # type: ignore[no-untyped-def]
|
|
515
|
+
conn = Connection._reverse_mapping[ssl]
|
|
547
516
|
try:
|
|
548
|
-
conn = Connection._reverse_mapping[ssl]
|
|
549
|
-
|
|
550
517
|
# The string passed to us is made up of multiple
|
|
551
518
|
# length-prefixed bytestrings. We need to split that into a
|
|
552
519
|
# list.
|
|
@@ -583,19 +550,26 @@ class _ALPNSelectHelper(_CallbackExceptionHelper):
|
|
|
583
550
|
return _lib.SSL_TLSEXT_ERR_NOACK
|
|
584
551
|
return _lib.SSL_TLSEXT_ERR_OK
|
|
585
552
|
except Exception as e:
|
|
586
|
-
|
|
553
|
+
conn._callback_problems.append(e)
|
|
587
554
|
return _lib.SSL_TLSEXT_ERR_ALERT_FATAL
|
|
588
555
|
|
|
556
|
+
# If an exception ever escapes ``wrapper`` (it should not: the only
|
|
557
|
+
# statement outside its ``try`` is the connection lookup, which cannot
|
|
558
|
+
# fail for an SSL object owned by a Connection), cffi prints it and
|
|
559
|
+
# returns this value instead of the default 0, which would be
|
|
560
|
+
# SSL_TLSEXT_ERR_OK and make OpenSSL read the never-assigned ``out``
|
|
561
|
+
# and ``outlen`` parameters.
|
|
589
562
|
self.callback = _ffi.callback(
|
|
590
563
|
(
|
|
591
564
|
"int (*)(SSL *, unsigned char **, unsigned char *, "
|
|
592
565
|
"const unsigned char *, unsigned int, void *)"
|
|
593
566
|
),
|
|
594
567
|
wrapper,
|
|
568
|
+
error=_lib.SSL_TLSEXT_ERR_ALERT_FATAL,
|
|
595
569
|
)
|
|
596
570
|
|
|
597
571
|
|
|
598
|
-
class _OCSPServerCallbackHelper
|
|
572
|
+
class _OCSPServerCallbackHelper:
|
|
599
573
|
"""
|
|
600
574
|
Wrap a callback such that it can be used as an OCSP callback for the server
|
|
601
575
|
side.
|
|
@@ -618,13 +592,10 @@ class _OCSPServerCallbackHelper(_CallbackExceptionHelper):
|
|
|
618
592
|
"""
|
|
619
593
|
|
|
620
594
|
def __init__(self, callback: _OCSPServerCallback[Any]) -> None:
|
|
621
|
-
_CallbackExceptionHelper.__init__(self)
|
|
622
|
-
|
|
623
595
|
@wraps(callback)
|
|
624
596
|
def wrapper(ssl, cdata): # type: ignore[no-untyped-def]
|
|
597
|
+
conn = Connection._reverse_mapping[ssl]
|
|
625
598
|
try:
|
|
626
|
-
conn = Connection._reverse_mapping[ssl]
|
|
627
|
-
|
|
628
599
|
# Extract the data if any was provided.
|
|
629
600
|
if cdata != _ffi.NULL:
|
|
630
601
|
data = _ffi.from_handle(cdata)
|
|
@@ -656,13 +627,13 @@ class _OCSPServerCallbackHelper(_CallbackExceptionHelper):
|
|
|
656
627
|
|
|
657
628
|
return 0
|
|
658
629
|
except Exception as e:
|
|
659
|
-
|
|
630
|
+
conn._callback_problems.append(e)
|
|
660
631
|
return 2 # SSL_TLSEXT_ERR_ALERT_FATAL
|
|
661
632
|
|
|
662
633
|
self.callback = _ffi.callback("int (*)(SSL *, void *)", wrapper)
|
|
663
634
|
|
|
664
635
|
|
|
665
|
-
class _OCSPClientCallbackHelper
|
|
636
|
+
class _OCSPClientCallbackHelper:
|
|
666
637
|
"""
|
|
667
638
|
Wrap a callback such that it can be used as an OCSP callback for the client
|
|
668
639
|
side.
|
|
@@ -685,13 +656,10 @@ class _OCSPClientCallbackHelper(_CallbackExceptionHelper):
|
|
|
685
656
|
"""
|
|
686
657
|
|
|
687
658
|
def __init__(self, callback: _OCSPClientCallback[Any]) -> None:
|
|
688
|
-
_CallbackExceptionHelper.__init__(self)
|
|
689
|
-
|
|
690
659
|
@wraps(callback)
|
|
691
660
|
def wrapper(ssl, cdata): # type: ignore[no-untyped-def]
|
|
661
|
+
conn = Connection._reverse_mapping[ssl]
|
|
692
662
|
try:
|
|
693
|
-
conn = Connection._reverse_mapping[ssl]
|
|
694
|
-
|
|
695
663
|
# Extract the data if any was provided.
|
|
696
664
|
if cdata != _ffi.NULL:
|
|
697
665
|
data = _ffi.from_handle(cdata)
|
|
@@ -714,23 +682,21 @@ class _OCSPClientCallbackHelper(_CallbackExceptionHelper):
|
|
|
714
682
|
return int(bool(valid))
|
|
715
683
|
|
|
716
684
|
except Exception as e:
|
|
717
|
-
|
|
685
|
+
conn._callback_problems.append(e)
|
|
718
686
|
# Return negative value if an exception is hit.
|
|
719
687
|
return -1
|
|
720
688
|
|
|
721
689
|
self.callback = _ffi.callback("int (*)(SSL *, void *)", wrapper)
|
|
722
690
|
|
|
723
691
|
|
|
724
|
-
class _CookieGenerateCallbackHelper
|
|
692
|
+
class _CookieGenerateCallbackHelper:
|
|
725
693
|
def __init__(self, callback: _CookieGenerateCallback) -> None:
|
|
726
|
-
_CallbackExceptionHelper.__init__(self)
|
|
727
|
-
|
|
728
694
|
max_cookie_len = getattr(_lib, "DTLS1_COOKIE_LENGTH", 255)
|
|
729
695
|
|
|
730
696
|
@wraps(callback)
|
|
731
697
|
def wrapper(ssl, out, outlen): # type: ignore[no-untyped-def]
|
|
698
|
+
conn = Connection._reverse_mapping[ssl]
|
|
732
699
|
try:
|
|
733
|
-
conn = Connection._reverse_mapping[ssl]
|
|
734
700
|
cookie = callback(conn)
|
|
735
701
|
if len(cookie) > max_cookie_len:
|
|
736
702
|
raise ValueError(
|
|
@@ -741,7 +707,7 @@ class _CookieGenerateCallbackHelper(_CallbackExceptionHelper):
|
|
|
741
707
|
outlen[0] = len(cookie)
|
|
742
708
|
return 1
|
|
743
709
|
except Exception as e:
|
|
744
|
-
|
|
710
|
+
conn._callback_problems.append(e)
|
|
745
711
|
# "a zero return value can be used to abort the handshake"
|
|
746
712
|
return 0
|
|
747
713
|
|
|
@@ -751,17 +717,15 @@ class _CookieGenerateCallbackHelper(_CallbackExceptionHelper):
|
|
|
751
717
|
)
|
|
752
718
|
|
|
753
719
|
|
|
754
|
-
class _CookieVerifyCallbackHelper
|
|
720
|
+
class _CookieVerifyCallbackHelper:
|
|
755
721
|
def __init__(self, callback: _CookieVerifyCallback) -> None:
|
|
756
|
-
_CallbackExceptionHelper.__init__(self)
|
|
757
|
-
|
|
758
722
|
@wraps(callback)
|
|
759
723
|
def wrapper(ssl, c_cookie, cookie_len): # type: ignore[no-untyped-def]
|
|
724
|
+
conn = Connection._reverse_mapping[ssl]
|
|
760
725
|
try:
|
|
761
|
-
conn = Connection._reverse_mapping[ssl]
|
|
762
726
|
return callback(conn, bytes(c_cookie[0:cookie_len]))
|
|
763
727
|
except Exception as e:
|
|
764
|
-
|
|
728
|
+
conn._callback_problems.append(e)
|
|
765
729
|
return 0
|
|
766
730
|
|
|
767
731
|
self.callback = _ffi.callback(
|
|
@@ -1968,9 +1932,9 @@ class Context:
|
|
|
1968
1932
|
|
|
1969
1933
|
|
|
1970
1934
|
class Connection:
|
|
1971
|
-
_reverse_mapping: typing.
|
|
1972
|
-
|
|
1973
|
-
)
|
|
1935
|
+
_reverse_mapping: typing.ClassVar[
|
|
1936
|
+
typing.MutableMapping[Any, Connection]
|
|
1937
|
+
] = WeakValueDictionary()
|
|
1974
1938
|
|
|
1975
1939
|
def __init__(
|
|
1976
1940
|
self, context: Context, socket: socket.socket | None = None
|
|
@@ -2003,6 +1967,16 @@ class Connection:
|
|
|
2003
1967
|
# avoid them getting freed.
|
|
2004
1968
|
self._alpn_select_callback_args: Any = None
|
|
2005
1969
|
|
|
1970
|
+
# Exceptions raised by callbacks (verify, ALPN selection, OCSP, DTLS
|
|
1971
|
+
# cookies) while OpenSSL was calling into Python on behalf of this
|
|
1972
|
+
# connection. They cannot be raised from inside the callback, so they
|
|
1973
|
+
# are recorded here and raised by the next method that OpenSSL
|
|
1974
|
+
# returns control to. They are kept on the connection rather than on
|
|
1975
|
+
# the (context-wide, shared) callback wrapper so that a connection
|
|
1976
|
+
# driven concurrently from another thread can never be handed an
|
|
1977
|
+
# exception that belongs to a different connection.
|
|
1978
|
+
self._callback_problems: list[Exception] = []
|
|
1979
|
+
|
|
2006
1980
|
# Reference the verify_callback of the Context. This ensures that if
|
|
2007
1981
|
# set_verify is called again after the SSL object has been created we
|
|
2008
1982
|
# do not point to a dangling reference
|
|
@@ -2046,13 +2020,19 @@ class Connection:
|
|
|
2046
2020
|
else:
|
|
2047
2021
|
return getattr(self._socket, name)
|
|
2048
2022
|
|
|
2023
|
+
def _raise_callback_problem(self) -> None:
|
|
2024
|
+
"""
|
|
2025
|
+
Raise an exception that was captured while running a callback on
|
|
2026
|
+
behalf of this connection, if there is one, after discarding whatever
|
|
2027
|
+
OpenSSL left on its error queue as a consequence of the callback
|
|
2028
|
+
failing.
|
|
2029
|
+
"""
|
|
2030
|
+
if self._callback_problems:
|
|
2031
|
+
_lib.ERR_clear_error()
|
|
2032
|
+
raise self._callback_problems.pop(0)
|
|
2033
|
+
|
|
2049
2034
|
def _raise_ssl_error(self, ssl: Any, result: int) -> None:
|
|
2050
|
-
|
|
2051
|
-
self._context._verify_helper.raise_if_problem()
|
|
2052
|
-
if self._context._alpn_select_helper is not None:
|
|
2053
|
-
self._context._alpn_select_helper.raise_if_problem()
|
|
2054
|
-
if self._context._ocsp_helper is not None:
|
|
2055
|
-
self._context._ocsp_helper.raise_if_problem()
|
|
2035
|
+
self._raise_callback_problem()
|
|
2056
2036
|
|
|
2057
2037
|
error = _lib.SSL_get_error(ssl, result)
|
|
2058
2038
|
if error == _lib.SSL_ERROR_WANT_READ:
|
|
@@ -2561,10 +2541,7 @@ class Connection:
|
|
|
2561
2541
|
# ClientHello with valid cookie, but keep trying'. So basically
|
|
2562
2542
|
# WantReadError. But it doesn't work correctly with _raise_ssl_error.
|
|
2563
2543
|
# So we raise it manually instead.
|
|
2564
|
-
|
|
2565
|
-
self._cookie_generate_helper.raise_if_problem()
|
|
2566
|
-
if self._cookie_verify_helper is not None:
|
|
2567
|
-
self._cookie_verify_helper.raise_if_problem()
|
|
2544
|
+
self._raise_callback_problem()
|
|
2568
2545
|
if result == 0:
|
|
2569
2546
|
raise WantReadError()
|
|
2570
2547
|
if result < 0:
|
|
@@ -2803,14 +2780,17 @@ class Connection:
|
|
|
2803
2780
|
"""
|
|
2804
2781
|
Retrieve the value of the master key for this session.
|
|
2805
2782
|
|
|
2806
|
-
:return:
|
|
2783
|
+
:return: The master key, or :obj:`None` if there is no session or the
|
|
2784
|
+
connection uses TLS 1.3, which has no master secret.
|
|
2807
2785
|
"""
|
|
2808
2786
|
session = _lib.SSL_get_session(self._ssl)
|
|
2809
2787
|
if session == _ffi.NULL:
|
|
2810
2788
|
return None
|
|
2811
2789
|
|
|
2812
2790
|
length = _lib.SSL_SESSION_get_master_key(session, _ffi.NULL, 0)
|
|
2813
|
-
|
|
2791
|
+
# TLS 1.3 has no master secret, so the length is 0.
|
|
2792
|
+
if length == 0:
|
|
2793
|
+
return None
|
|
2814
2794
|
outp = _no_zero_allocator("unsigned char[]", length)
|
|
2815
2795
|
_lib.SSL_SESSION_get_master_key(session, outp, length)
|
|
2816
2796
|
return _ffi.buffer(outp, length)[:]
|
|
@@ -5,6 +5,7 @@ import datetime
|
|
|
5
5
|
import functools
|
|
6
6
|
import sys
|
|
7
7
|
import typing
|
|
8
|
+
import warnings
|
|
8
9
|
from base64 import b16encode
|
|
9
10
|
from collections.abc import Sequence
|
|
10
11
|
from functools import partial
|
|
@@ -21,7 +22,6 @@ else:
|
|
|
21
22
|
|
|
22
23
|
from cryptography import utils, x509
|
|
23
24
|
from cryptography.hazmat.primitives.asymmetric import (
|
|
24
|
-
dsa,
|
|
25
25
|
ec,
|
|
26
26
|
ed448,
|
|
27
27
|
ed25519,
|
|
@@ -72,16 +72,28 @@ __all__ = [
|
|
|
72
72
|
"load_publickey",
|
|
73
73
|
]
|
|
74
74
|
|
|
75
|
+
# cryptography deprecated DSA in 51.0.0, and accessing these names emits a
|
|
76
|
+
# warning. We only use them to describe the types of keys we accept, so don't
|
|
77
|
+
# warn users who aren't using DSA.
|
|
78
|
+
with warnings.catch_warnings():
|
|
79
|
+
warnings.simplefilter("ignore", utils.CryptographyDeprecationWarning)
|
|
80
|
+
from cryptography.hazmat.primitives.asymmetric.dsa import (
|
|
81
|
+
DSAPrivateKey as _DSAPrivateKey,
|
|
82
|
+
)
|
|
83
|
+
from cryptography.hazmat.primitives.asymmetric.dsa import (
|
|
84
|
+
DSAPublicKey as _DSAPublicKey,
|
|
85
|
+
)
|
|
86
|
+
|
|
75
87
|
|
|
76
88
|
_PrivateKey = Union[
|
|
77
|
-
|
|
89
|
+
_DSAPrivateKey,
|
|
78
90
|
ec.EllipticCurvePrivateKey,
|
|
79
91
|
ed25519.Ed25519PrivateKey,
|
|
80
92
|
ed448.Ed448PrivateKey,
|
|
81
93
|
rsa.RSAPrivateKey,
|
|
82
94
|
]
|
|
83
95
|
_PublicKey = Union[
|
|
84
|
-
|
|
96
|
+
_DSAPublicKey,
|
|
85
97
|
ec.EllipticCurvePublicKey,
|
|
86
98
|
ed25519.Ed25519PublicKey,
|
|
87
99
|
ed448.Ed448PublicKey,
|
|
@@ -203,12 +215,14 @@ def _get_asn1_time(timestamp: Any) -> bytes | None:
|
|
|
203
215
|
format. Or C{None} if the object contains no time value.
|
|
204
216
|
"""
|
|
205
217
|
string_timestamp = _ffi.cast("ASN1_STRING*", timestamp)
|
|
206
|
-
|
|
218
|
+
string_length = _lib.ASN1_STRING_length(string_timestamp)
|
|
219
|
+
if string_length == 0:
|
|
207
220
|
return None
|
|
208
221
|
elif (
|
|
209
222
|
_lib.ASN1_STRING_type(string_timestamp) == _lib.V_ASN1_GENERALIZEDTIME
|
|
210
223
|
):
|
|
211
|
-
|
|
224
|
+
string_data = _lib.ASN1_STRING_get0_data(string_timestamp)
|
|
225
|
+
return _ffi.buffer(string_data, string_length)[:]
|
|
212
226
|
else:
|
|
213
227
|
generalized_timestamp = _ffi.new("ASN1_GENERALIZEDTIME**")
|
|
214
228
|
_lib.ASN1_TIME_to_generalizedtime(timestamp, generalized_timestamp)
|
|
@@ -216,7 +230,8 @@ def _get_asn1_time(timestamp: Any) -> bytes | None:
|
|
|
216
230
|
|
|
217
231
|
string_timestamp = _ffi.cast("ASN1_STRING*", generalized_timestamp[0])
|
|
218
232
|
string_data = _lib.ASN1_STRING_get0_data(string_timestamp)
|
|
219
|
-
|
|
233
|
+
string_length = _lib.ASN1_STRING_length(string_timestamp)
|
|
234
|
+
string_result = _ffi.buffer(string_data, string_length)[:]
|
|
220
235
|
_lib.ASN1_GENERALIZEDTIME_free(generalized_timestamp[0])
|
|
221
236
|
return string_result
|
|
222
237
|
|
|
@@ -285,8 +300,8 @@ class PKey:
|
|
|
285
300
|
if not isinstance(
|
|
286
301
|
crypto_key,
|
|
287
302
|
(
|
|
288
|
-
|
|
289
|
-
|
|
303
|
+
_DSAPrivateKey,
|
|
304
|
+
_DSAPublicKey,
|
|
290
305
|
ec.EllipticCurvePrivateKey,
|
|
291
306
|
ec.EllipticCurvePublicKey,
|
|
292
307
|
ed25519.Ed25519PrivateKey,
|
|
@@ -309,7 +324,7 @@ class PKey:
|
|
|
309
324
|
if isinstance(
|
|
310
325
|
crypto_key,
|
|
311
326
|
(
|
|
312
|
-
|
|
327
|
+
_DSAPublicKey,
|
|
313
328
|
ec.EllipticCurvePublicKey,
|
|
314
329
|
ed25519.Ed25519PublicKey,
|
|
315
330
|
ed448.Ed448PublicKey,
|
|
@@ -1001,14 +1016,18 @@ class X509:
|
|
|
1001
1016
|
if not isinstance(serial, int):
|
|
1002
1017
|
raise TypeError("serial must be an integer")
|
|
1003
1018
|
|
|
1004
|
-
|
|
1019
|
+
if serial < 0:
|
|
1020
|
+
raise ValueError("serial must be non-negative")
|
|
1021
|
+
|
|
1022
|
+
hex_serial = f"{serial:x}"
|
|
1005
1023
|
hex_serial_bytes = hex_serial.encode("ascii")
|
|
1006
1024
|
|
|
1007
1025
|
bignum_serial = _ffi.new("BIGNUM**")
|
|
1008
1026
|
|
|
1009
|
-
# BN_hex2bn
|
|
1027
|
+
# BN_hex2bn returns the count of characters consumed, or 0 on error --
|
|
1028
|
+
# not a pointer, so it must not be compared against NULL.
|
|
1010
1029
|
result = _lib.BN_hex2bn(bignum_serial, hex_serial_bytes)
|
|
1011
|
-
_openssl_assert(result !=
|
|
1030
|
+
_openssl_assert(result != 0)
|
|
1012
1031
|
|
|
1013
1032
|
asn1_serial = _lib.BN_to_ASN1_INTEGER(bignum_serial[0], _ffi.NULL)
|
|
1014
1033
|
_lib.BN_free(bignum_serial[0])
|
|
@@ -17,12 +17,12 @@ __all__ = [
|
|
|
17
17
|
"__version__",
|
|
18
18
|
]
|
|
19
19
|
|
|
20
|
-
__version__ = "26.
|
|
20
|
+
__version__ = "26.5.1"
|
|
21
21
|
|
|
22
22
|
__title__ = "pyOpenSSL"
|
|
23
23
|
__uri__ = "https://pyopenssl.org/"
|
|
24
24
|
__summary__ = "Python wrapper module around the OpenSSL library"
|
|
25
25
|
__author__ = "The pyOpenSSL developers"
|
|
26
26
|
__email__ = "cryptography-dev@python.org"
|
|
27
|
-
__license__ = "Apache
|
|
27
|
+
__license__ = "Apache-2.0"
|
|
28
28
|
__copyright__ = f"Copyright 2001-2026 {__author__}"
|
|
@@ -1,15 +1,14 @@
|
|
|
1
1
|
Metadata-Version: 2.4
|
|
2
2
|
Name: pyOpenSSL
|
|
3
|
-
Version: 26.
|
|
3
|
+
Version: 26.5.1
|
|
4
4
|
Summary: Python wrapper module around the OpenSSL library
|
|
5
5
|
Home-page: https://pyopenssl.org/
|
|
6
6
|
Author: The pyOpenSSL developers
|
|
7
7
|
Author-email: cryptography-dev@python.org
|
|
8
|
-
License: Apache
|
|
8
|
+
License: Apache-2.0
|
|
9
9
|
Project-URL: Source, https://github.com/pyca/pyopenssl
|
|
10
10
|
Classifier: Development Status :: 6 - Mature
|
|
11
11
|
Classifier: Intended Audience :: Developers
|
|
12
|
-
Classifier: License :: OSI Approved :: Apache Software License
|
|
13
12
|
Classifier: Operating System :: MacOS :: MacOS X
|
|
14
13
|
Classifier: Operating System :: Microsoft :: Windows
|
|
15
14
|
Classifier: Operating System :: POSIX
|
|
@@ -19,6 +18,7 @@ Classifier: Programming Language :: Python :: 3.10
|
|
|
19
18
|
Classifier: Programming Language :: Python :: 3.11
|
|
20
19
|
Classifier: Programming Language :: Python :: 3.12
|
|
21
20
|
Classifier: Programming Language :: Python :: 3.13
|
|
21
|
+
Classifier: Programming Language :: Python :: 3.14
|
|
22
22
|
Classifier: Programming Language :: Python :: Implementation :: CPython
|
|
23
23
|
Classifier: Programming Language :: Python :: Implementation :: PyPy
|
|
24
24
|
Classifier: Topic :: Security :: Cryptography
|
|
@@ -26,7 +26,7 @@ Classifier: Topic :: Software Development :: Libraries :: Python Modules
|
|
|
26
26
|
Classifier: Topic :: System :: Networking
|
|
27
27
|
Requires-Python: >=3.9
|
|
28
28
|
License-File: LICENSE
|
|
29
|
-
Requires-Dist: cryptography<
|
|
29
|
+
Requires-Dist: cryptography<52,>=49.0.0
|
|
30
30
|
Requires-Dist: typing-extensions>=4.9; python_version < "3.13"
|
|
31
31
|
Provides-Extra: test
|
|
32
32
|
Requires-Dist: pytest-rerunfailures; extra == "test"
|
|
@@ -95,6 +95,59 @@ You can also join ``#pyca`` on ``irc.libera.chat`` to ask questions or get invol
|
|
|
95
95
|
Release Information
|
|
96
96
|
===================
|
|
97
97
|
|
|
98
|
+
26.5.1 (2026-12-02)
|
|
99
|
+
-------------------
|
|
100
|
+
|
|
101
|
+
Backward-incompatible changes:
|
|
102
|
+
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
|
|
103
|
+
|
|
104
|
+
Deprecations:
|
|
105
|
+
^^^^^^^^^^^^^
|
|
106
|
+
|
|
107
|
+
Changes:
|
|
108
|
+
^^^^^^^^
|
|
109
|
+
|
|
110
|
+
- Fixed invalid markup in the changelog that prevented 26.5.0 from being uploaded to PyPI. There are no other changes from 26.5.0.
|
|
111
|
+
|
|
112
|
+
|
|
113
|
+
26.5.0 (2026-12-02)
|
|
114
|
+
-------------------
|
|
115
|
+
|
|
116
|
+
Backward-incompatible changes:
|
|
117
|
+
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
|
|
118
|
+
|
|
119
|
+
- ``OpenSSL.crypto.X509.set_serial_number()`` now raises ``ValueError`` for a negative serial number, which
|
|
120
|
+
`RFC 5280 section 4.1.2.2 <https://datatracker.ietf.org/doc/html/rfc5280#section-4.1.2.2>`_ does not permit.
|
|
121
|
+
Passing one previously crashed the interpreter.
|
|
122
|
+
[`#1534 <https://github.com/pyca/pyopenssl/pull/1534>`_]
|
|
123
|
+
|
|
124
|
+
Deprecations:
|
|
125
|
+
^^^^^^^^^^^^^
|
|
126
|
+
|
|
127
|
+
Changes:
|
|
128
|
+
^^^^^^^^
|
|
129
|
+
|
|
130
|
+
- Fixed a race in which an exception raised by a verify, ALPN selection, OCSP, or DTLS cookie callback for one ``Connection`` could be raised on an unrelated ``Connection`` created from the same ``Context`` and used concurrently from another thread. Exceptions from these callbacks are now tracked per ``Connection``. Discovered and reported by SecDim Security Research.
|
|
131
|
+
- Fixed exceptions raised by a verify callback registered with ``Connection.set_verify`` being swallowed instead of being propagated to the caller.
|
|
132
|
+
- ``Connection.master_key()`` now returns ``None`` for TLS 1.3 connections, which have no master secret, instead of raising ``OpenSSL.SSL.Error``.
|
|
133
|
+
- Maximum supported ``cryptography`` version is now 51.x.
|
|
134
|
+
|
|
135
|
+
|
|
136
|
+
26.4.0 (2026-08-01)
|
|
137
|
+
-------------------
|
|
138
|
+
|
|
139
|
+
Backward-incompatible changes:
|
|
140
|
+
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
|
|
141
|
+
|
|
142
|
+
Deprecations:
|
|
143
|
+
^^^^^^^^^^^^^
|
|
144
|
+
|
|
145
|
+
Changes:
|
|
146
|
+
^^^^^^^^
|
|
147
|
+
|
|
148
|
+
- Maximum supported ``cryptography`` version is now 50.x.
|
|
149
|
+
|
|
150
|
+
|
|
98
151
|
26.3.0 (2026-06-12)
|
|
99
152
|
-------------------
|
|
100
153
|
|
|
@@ -1471,6 +1471,23 @@ class TestX509:
|
|
|
1471
1471
|
certificate.set_serial_number(2**128 + 1)
|
|
1472
1472
|
assert certificate.get_serial_number() == 2**128 + 1
|
|
1473
1473
|
|
|
1474
|
+
def test_negative_serial_number(self) -> None:
|
|
1475
|
+
"""
|
|
1476
|
+
`X509.set_serial_number` rejects a negative serial number, which
|
|
1477
|
+
RFC 5280 section 4.1.2.2 does not permit. Before this was checked,
|
|
1478
|
+
a negative value crashed the interpreter.
|
|
1479
|
+
"""
|
|
1480
|
+
certificate = X509()
|
|
1481
|
+
for serial in [-1, -255, -(2**128 + 1)]:
|
|
1482
|
+
with pytest.raises(ValueError):
|
|
1483
|
+
certificate.set_serial_number(serial)
|
|
1484
|
+
|
|
1485
|
+
# A serial that was set earlier is left alone by the rejected call.
|
|
1486
|
+
certificate.set_serial_number(1)
|
|
1487
|
+
with pytest.raises(ValueError):
|
|
1488
|
+
certificate.set_serial_number(-1)
|
|
1489
|
+
assert certificate.get_serial_number() == 1
|
|
1490
|
+
|
|
1474
1491
|
def _setBoundTest(
|
|
1475
1492
|
self,
|
|
1476
1493
|
get: typing.Callable[[X509], bytes | None],
|
|
@@ -2004,13 +2021,7 @@ def _runopenssl(pem: bytes, *args: bytes) -> bytes:
|
|
|
2004
2021
|
the given PEM to its stdin. Not safe for quotes.
|
|
2005
2022
|
"""
|
|
2006
2023
|
proc = Popen([b"openssl", *list(args)], stdin=PIPE, stdout=PIPE)
|
|
2007
|
-
|
|
2008
|
-
assert proc.stdout is not None
|
|
2009
|
-
proc.stdin.write(pem)
|
|
2010
|
-
proc.stdin.close()
|
|
2011
|
-
output = proc.stdout.read()
|
|
2012
|
-
proc.stdout.close()
|
|
2013
|
-
proc.wait()
|
|
2024
|
+
output, _ = proc.communicate(pem)
|
|
2014
2025
|
return output
|
|
2015
2026
|
|
|
2016
2027
|
|
|
@@ -1877,7 +1877,9 @@ class TestContext:
|
|
|
1877
1877
|
context.set_tmp_ecdh(curve)
|
|
1878
1878
|
|
|
1879
1879
|
awslc_unsupported_curves = {
|
|
1880
|
+
"BRAINPOOLP224R1",
|
|
1880
1881
|
"BRAINPOOLP256R1",
|
|
1882
|
+
"BRAINPOOLP320R1",
|
|
1881
1883
|
"BRAINPOOLP384R1",
|
|
1882
1884
|
"BRAINPOOLP512R1",
|
|
1883
1885
|
"SECP192R1",
|
|
@@ -2399,6 +2401,46 @@ class TestApplicationLayerProtoNegotiation:
|
|
|
2399
2401
|
interact_in_memory(server, client)
|
|
2400
2402
|
assert select_args == [(server, [b"http/1.1", b"spdy/2"])]
|
|
2401
2403
|
|
|
2404
|
+
def test_alpn_callback_exception_stays_with_its_connection(self) -> None:
|
|
2405
|
+
"""
|
|
2406
|
+
An exception raised by the ALPN select callback while serving one
|
|
2407
|
+
connection is only ever raised on that connection, even though every
|
|
2408
|
+
connection created from the same `Context` shares the callback
|
|
2409
|
+
wrapper. Otherwise, with connections driven from several threads, an
|
|
2410
|
+
unrelated connection could be handed another connection's exception.
|
|
2411
|
+
"""
|
|
2412
|
+
|
|
2413
|
+
def select(conn: Connection, options: list[bytes]) -> bytes:
|
|
2414
|
+
return options[0]
|
|
2415
|
+
|
|
2416
|
+
server_context = Context(SSLv23_METHOD)
|
|
2417
|
+
server_context.set_alpn_select_callback(select)
|
|
2418
|
+
server_context.use_privatekey(
|
|
2419
|
+
load_privatekey(FILETYPE_PEM, server_key_pem)
|
|
2420
|
+
)
|
|
2421
|
+
server_context.use_certificate(
|
|
2422
|
+
load_certificate(FILETYPE_PEM, server_cert_pem)
|
|
2423
|
+
)
|
|
2424
|
+
|
|
2425
|
+
client_context = Context(SSLv23_METHOD)
|
|
2426
|
+
client_context.set_alpn_protos([b"http/1.1"])
|
|
2427
|
+
|
|
2428
|
+
failing = Connection(server_context, None)
|
|
2429
|
+
other = Connection(server_context, None)
|
|
2430
|
+
client = Connection(client_context, None)
|
|
2431
|
+
|
|
2432
|
+
# Simulate the callback having raised on ``failing`` in another
|
|
2433
|
+
# thread that has not yet had the chance to surface the exception.
|
|
2434
|
+
failing._callback_problems.append(ValueError("belongs to failing"))
|
|
2435
|
+
|
|
2436
|
+
# The unrelated connection is unaffected...
|
|
2437
|
+
handshake_in_memory(client, other)
|
|
2438
|
+
assert other.get_alpn_proto_negotiated() == b"http/1.1"
|
|
2439
|
+
|
|
2440
|
+
# ...and the exception is still delivered to the right connection.
|
|
2441
|
+
with pytest.raises(ValueError, match="belongs to failing"):
|
|
2442
|
+
failing.do_handshake()
|
|
2443
|
+
|
|
2402
2444
|
|
|
2403
2445
|
class TestSession:
|
|
2404
2446
|
"""
|
|
@@ -3012,6 +3054,32 @@ class TestConnection:
|
|
|
3012
3054
|
with pytest.raises(TypeError):
|
|
3013
3055
|
conn.set_verify(VERIFY_PEER, "not a callable") # type: ignore[arg-type]
|
|
3014
3056
|
|
|
3057
|
+
def test_set_verify_callback_exception(self) -> None:
|
|
3058
|
+
"""
|
|
3059
|
+
If the verify callback passed to `Connection.set_verify` raises an
|
|
3060
|
+
exception, verification fails and the exception is propagated to the
|
|
3061
|
+
caller of `Connection.do_handshake`.
|
|
3062
|
+
"""
|
|
3063
|
+
server_context = Context(SSLv23_METHOD)
|
|
3064
|
+
server_context.use_privatekey(
|
|
3065
|
+
load_privatekey(FILETYPE_PEM, root_key_pem)
|
|
3066
|
+
)
|
|
3067
|
+
server_context.use_certificate(
|
|
3068
|
+
load_certificate(FILETYPE_PEM, root_cert_pem)
|
|
3069
|
+
)
|
|
3070
|
+
server = Connection(server_context, None)
|
|
3071
|
+
|
|
3072
|
+
def verify_callback(
|
|
3073
|
+
conn: Connection, cert: X509, err: int, depth: int, ok: int
|
|
3074
|
+
) -> bool:
|
|
3075
|
+
raise KeyError("silly verify failure")
|
|
3076
|
+
|
|
3077
|
+
client = Connection(Context(SSLv23_METHOD), None)
|
|
3078
|
+
client.set_verify(VERIFY_PEER, verify_callback)
|
|
3079
|
+
|
|
3080
|
+
with pytest.raises(KeyError, match="silly verify failure"):
|
|
3081
|
+
handshake_in_memory(client, server)
|
|
3082
|
+
|
|
3015
3083
|
def test_set_verify_callback_reference(self) -> None:
|
|
3016
3084
|
"""
|
|
3017
3085
|
The callback for certificate verification should only be forgotten if
|
|
@@ -4259,8 +4327,13 @@ class TestMemoryBIO:
|
|
|
4259
4327
|
# speaking any more.
|
|
4260
4328
|
assert interact_in_memory(client_conn, server_conn) is None
|
|
4261
4329
|
|
|
4262
|
-
# Now that the handshake is done, there should be
|
|
4263
|
-
|
|
4330
|
+
# Now that the handshake is done, there should be nonces. For TLS <=
|
|
4331
|
+
# 1.2 there is also a master secret; TLS 1.3 has none, so master_key()
|
|
4332
|
+
# may be None there (it is with OpenSSL 4.1+) and must not raise.
|
|
4333
|
+
if server_conn.get_protocol_version() < TLS1_3_VERSION:
|
|
4334
|
+
assert server_conn.master_key() is not None
|
|
4335
|
+
else:
|
|
4336
|
+
server_conn.master_key()
|
|
4264
4337
|
assert server_conn.client_random() is not None
|
|
4265
4338
|
assert server_conn.server_random() is not None
|
|
4266
4339
|
assert server_conn.client_random() == client_conn.client_random()
|
|
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
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|