Skip to content

Commit 9f82d97

Browse files
authored
Raise cryptography version and prepare the 24.3.0 release (#1381)
Also fixes tests under OpenSSL 3.4.0
1 parent 7e1660b commit 9f82d97

File tree

9 files changed

+30
-22
lines changed

9 files changed

+30
-22
lines changed

.github/workflows/ci.yml

+2
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@ jobs:
77
linux:
88
runs-on: ${{ matrix.PYTHON.OS || 'ubuntu-22.04' }}
99
strategy:
10+
fail-fast: false
1011
matrix:
1112
PYTHON:
1213
# Base builds
@@ -66,6 +67,7 @@ jobs:
6667
runs-on: ubuntu-latest
6768
container: ghcr.io/pyca/cryptography-runner-${{ matrix.TEST.CONTAINER }}
6869
strategy:
70+
fail-fast: false
6971
matrix:
7072
TEST:
7173
# cryptographyMain used since there's no wheel

CHANGELOG.rst

+2-1
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ Changelog
44
Versions are year-based with a strict backward-compatibility policy.
55
The third digit is only for regressions.
66

7-
24.3.0 (UNRELEASED)
7+
24.3.0 (2024-11-27)
88
-------------------
99

1010
Backward-incompatible changes:
@@ -25,6 +25,7 @@ Deprecations:
2525
Changes:
2626
^^^^^^^^
2727

28+
* ``cryptography`` maximum version has been increased to 44.0.x.
2829
* ``OpenSSL.SSL.Connection.get_certificate``, ``OpenSSL.SSL.Connection.get_peer_certificate``, ``OpenSSL.SSL.Connection.get_peer_cert_chain``, and ``OpenSSL.SSL.Connection.get_verified_chain`` now take an ``as_cryptography`` keyword-argument. When ``True`` is passed then ``cryptography.x509.Certificate`` are returned, instead of ``OpenSSL.crypto.X509``. In the future, passing ``False`` (the default) will be deprecated.
2930

3031

pyproject.toml

+2
Original file line numberDiff line numberDiff line change
@@ -42,6 +42,8 @@ testpaths = ["tests"]
4242
[tool.ruff]
4343
lint.select = ['E', 'F', 'I', 'W', 'UP', 'RUF']
4444
line-length = 79
45+
# Remove if/when we move setup.py python-requires metadata to pyproject.toml
46+
target-version = "py37"
4547

4648
[tool.ruff.lint.isort]
4749
known-first-party = ["OpenSSL", "tests"]

setup.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -94,7 +94,7 @@ def find_meta(meta):
9494
packages=find_packages(where="src"),
9595
package_dir={"": "src"},
9696
install_requires=[
97-
"cryptography>=41.0.5,<44",
97+
"cryptography>=41.0.5,<45",
9898
],
9999
extras_require={
100100
"test": ["pytest-rerunfailures", "pretend", "pytest>=3.0.1"],

src/OpenSSL/SSL.py

+12-13
Original file line numberDiff line numberDiff line change
@@ -4,11 +4,12 @@
44
import socket
55
import typing
66
import warnings
7+
from collections.abc import Sequence
78
from errno import errorcode
89
from functools import partial, wraps
910
from itertools import chain, count
1011
from sys import platform
11-
from typing import Any, Callable, List, Optional, Sequence, TypeVar
12+
from typing import Any, Callable, Optional, TypeVar
1213
from weakref import WeakValueDictionary
1314

1415
from cryptography import x509
@@ -288,7 +289,7 @@ class _NoOverlappingProtocols:
288289
_ALPNSelectCallback = Callable[
289290
[
290291
"Connection",
291-
typing.Union[List[bytes], _NoOverlappingProtocols],
292+
typing.Union[typing.List[bytes], _NoOverlappingProtocols],
292293
],
293294
None,
294295
]
@@ -766,7 +767,7 @@ def _asFileDescriptor(obj: Any) -> int:
766767
raise TypeError("argument must be an int, or have a fileno() method.")
767768
elif fd < 0:
768769
raise ValueError(
769-
"file descriptor cannot be a negative integer (%i)" % (fd,)
770+
f"file descriptor cannot be a negative integer ({fd:i})"
770771
)
771772

772773
return fd
@@ -1952,18 +1953,16 @@ def _raise_ssl_error(self, ssl: Any, result: int) -> None:
19521953
# TODO: This is untested.
19531954
raise WantX509LookupError()
19541955
elif error == _lib.SSL_ERROR_SYSCALL:
1955-
if _lib.ERR_peek_error() == 0:
1956-
if result < 0:
1957-
if platform == "win32":
1958-
errno = _ffi.getwinerror()[0]
1959-
else:
1960-
errno = _ffi.errno
1961-
1962-
if errno != 0:
1963-
raise SysCallError(errno, errorcode.get(errno))
1956+
if platform == "win32":
1957+
errno = _ffi.getwinerror()[0]
1958+
else:
1959+
errno = _ffi.errno
1960+
if _lib.ERR_peek_error() == 0 or errno != 0:
1961+
if result < 0 and errno != 0:
1962+
raise SysCallError(errno, errorcode.get(errno))
19641963
raise SysCallError(-1, "Unexpected EOF")
19651964
else:
1966-
# TODO: This is untested.
1965+
# TODO: This is untested, but I think twisted hits it?
19671966
_raise_current_error()
19681967
elif error == _lib.SSL_ERROR_SSL and _lib.ERR_peek_error() != 0:
19691968
# In 3.0.x an unexpected EOF no longer triggers syscall error

src/OpenSSL/_util.py

+5-3
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,9 @@
1+
from __future__ import annotations
2+
13
import os
24
import sys
35
import warnings
4-
from typing import Any, Callable, NoReturn, Type, Union
6+
from typing import Any, Callable, NoReturn, Union
57

68
from cryptography.hazmat.bindings.openssl.binding import Binding
79

@@ -31,7 +33,7 @@ def text(charp: Any) -> str:
3133
return ffi.string(charp).decode("utf-8")
3234

3335

34-
def exception_from_error_queue(exception_type: Type[Exception]) -> NoReturn:
36+
def exception_from_error_queue(exception_type: type[Exception]) -> NoReturn:
3537
"""
3638
Convert an OpenSSL library failure into a Python exception.
3739
@@ -57,7 +59,7 @@ def exception_from_error_queue(exception_type: Type[Exception]) -> NoReturn:
5759
raise exception_type(errors)
5860

5961

60-
def make_assert(error: Type[Exception]) -> Callable[[bool], Any]:
62+
def make_assert(error: type[Exception]) -> Callable[[bool], Any]:
6163
"""
6264
Create an assert function that uses :func:`exception_from_error_queue` to
6365
raise an exception wrapped by *error*.

src/OpenSSL/crypto.py

+1-2
Original file line numberDiff line numberDiff line change
@@ -6,13 +6,12 @@
66
import typing
77
import warnings
88
from base64 import b16encode
9+
from collections.abc import Iterable, Sequence
910
from functools import partial
1011
from os import PathLike
1112
from typing import (
1213
Any,
1314
Callable,
14-
Iterable,
15-
Sequence,
1615
Union,
1716
)
1817

src/OpenSSL/version.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@
1717
"__version__",
1818
]
1919

20-
__version__ = "24.2.1"
20+
__version__ = "24.3.0"
2121

2222
__title__ = "pyOpenSSL"
2323
__uri__ = "https://pyopenssl.org/"

tests/test_ssl.py

+4-1
Original file line numberDiff line numberDiff line change
@@ -3832,7 +3832,10 @@ def test_unexpected_EOF(self):
38323832
if platform == "win32":
38333833
assert err.value.args == (10054, "WSAECONNRESET")
38343834
else:
3835-
assert err.value.args == (-1, "Unexpected EOF")
3835+
assert err.value.args in [
3836+
(-1, "Unexpected EOF"),
3837+
(54, "ECONNRESET"),
3838+
]
38363839

38373840
def _check_client_ca_list(self, func):
38383841
"""

0 commit comments

Comments
 (0)