Skip to content

Commit 12bc43b

Browse files
authored
work around openssl 3.1.0 bug and bump for 23.1.1 (#1204)
* work around openssl 3.1.0 bug and bump for 23.1.1 * remove a CI job that can't succeed cryptographyMain does not support 3.6
1 parent 240ae6f commit 12bc43b

File tree

5 files changed

+33
-4
lines changed

5 files changed

+33
-4
lines changed

.github/workflows/ci.yml

-1
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,6 @@ jobs:
2020
- {VERSION: "pypy-3.9", TOXENV: "pypy3"}
2121
- {VERSION: "3.11", TOXENV: "py311-useWheel", OS: "windows-2022" }
2222
# -cryptographyMain
23-
- {VERSION: "3.6", TOXENV: "py36-cryptographyMain", OS: "ubuntu-20.04"}
2423
- {VERSION: "3.7", TOXENV: "py37-cryptographyMain"}
2524
- {VERSION: "3.8", TOXENV: "py38-cryptographyMain"}
2625
- {VERSION: "3.9", TOXENV: "py39-cryptographyMain"}

CHANGELOG.rst

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

7+
23.1.1 (2023-03-28)
8+
-------------------
9+
10+
Backward-incompatible changes:
11+
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
12+
13+
Deprecations:
14+
^^^^^^^^^^^^^
15+
16+
Changes:
17+
^^^^^^^^
18+
19+
- Worked around an issue in OpenSSL 3.1.0 which caused `X509Extension.get_short_name` to raise an exception when no short name was known to OpenSSL.
20+
`#1204 <https://github.com/pyca/pyopenssl/pull/1204>`_.
21+
722
23.1.0 (2023-03-24)
823
-------------------
924

@@ -44,7 +59,7 @@ Backward-incompatible changes:
4459
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
4560

4661
- Remove support for SSLv2 and SSLv3.
47-
- The minimum ``cryptography`` version is now 38.0.x (and we now pin releases
62+
- The minimum ``cryptography`` version is now 38.0.x (and we now pin releases
4863
against ``cryptography`` major versions to prevent future breakage)
4964
- The ``OpenSSL.crypto.X509StoreContextError`` exception has been refactored,
5065
changing its internal attributes.

src/OpenSSL/crypto.py

+8-1
Original file line numberDiff line numberDiff line change
@@ -904,7 +904,14 @@ def get_short_name(self) -> bytes:
904904
"""
905905
obj = _lib.X509_EXTENSION_get_object(self._extension)
906906
nid = _lib.OBJ_obj2nid(obj)
907-
return _ffi.string(_lib.OBJ_nid2sn(nid))
907+
# OpenSSL 3.1.0 has a bug where nid2sn returns NULL for NIDs that
908+
# previously returned UNDEF. This is a workaround for that issue.
909+
# https://github.com/openssl/openssl/commit/908ba3ed9adbb3df90f76
910+
buf = _lib.OBJ_nid2sn(nid)
911+
if buf != _ffi.NULL:
912+
return _ffi.string(buf)
913+
else:
914+
return b"UNDEF"
908915

909916
def get_data(self) -> bytes:
910917
"""

src/OpenSSL/version.py

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

20-
__version__ = "23.1.0"
20+
__version__ = "23.1.1"
2121

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

tests/test_crypto.py

+8
Original file line numberDiff line numberDiff line change
@@ -1681,6 +1681,14 @@ def test_get_extensions(self):
16811681
exts = request.get_extensions()
16821682
assert len(exts) == 2
16831683

1684+
def test_undef_oid(self):
1685+
assert (
1686+
X509Extension(
1687+
b"1.2.3.4.5.6.7", False, b"DER:05:00"
1688+
).get_short_name()
1689+
== b"UNDEF"
1690+
)
1691+
16841692
def test_add_extensions_wrong_args(self):
16851693
"""
16861694
`X509Req.add_extensions` raises `TypeError` if called with a

0 commit comments

Comments
 (0)