pyOpenSSL 26.2.0__tar.gz → 26.4.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-26.2.0 → pyopenssl-26.4.0}/CHANGELOG.rst +41 -0
- {pyopenssl-26.2.0/src/pyOpenSSL.egg-info → pyopenssl-26.4.0}/PKG-INFO +45 -5
- {pyopenssl-26.2.0 → pyopenssl-26.4.0}/doc/api/crypto.rst +1 -18
- {pyopenssl-26.2.0 → pyopenssl-26.4.0}/doc/introduction.rst +1 -1
- {pyopenssl-26.2.0 → pyopenssl-26.4.0}/noxfile.py +1 -1
- {pyopenssl-26.2.0 → pyopenssl-26.4.0}/setup.py +3 -7
- {pyopenssl-26.2.0 → pyopenssl-26.4.0}/src/OpenSSL/SSL.py +68 -2
- {pyopenssl-26.2.0 → pyopenssl-26.4.0}/src/OpenSSL/_util.py +1 -4
- {pyopenssl-26.2.0 → pyopenssl-26.4.0}/src/OpenSSL/crypto.py +82 -277
- {pyopenssl-26.2.0 → pyopenssl-26.4.0}/src/OpenSSL/version.py +1 -1
- {pyopenssl-26.2.0 → pyopenssl-26.4.0/src/pyOpenSSL.egg-info}/PKG-INFO +45 -5
- {pyopenssl-26.2.0 → pyopenssl-26.4.0}/src/pyOpenSSL.egg-info/requires.txt +2 -2
- {pyopenssl-26.2.0 → pyopenssl-26.4.0}/tests/test_crypto.py +6 -218
- {pyopenssl-26.2.0 → pyopenssl-26.4.0}/tests/test_ssl.py +42 -26
- {pyopenssl-26.2.0 → pyopenssl-26.4.0}/CODE_OF_CONDUCT.rst +0 -0
- {pyopenssl-26.2.0 → pyopenssl-26.4.0}/CONTRIBUTING.rst +0 -0
- {pyopenssl-26.2.0 → pyopenssl-26.4.0}/INSTALL.rst +0 -0
- {pyopenssl-26.2.0 → pyopenssl-26.4.0}/LICENSE +0 -0
- {pyopenssl-26.2.0 → pyopenssl-26.4.0}/MANIFEST.in +0 -0
- {pyopenssl-26.2.0 → pyopenssl-26.4.0}/README.rst +0 -0
- {pyopenssl-26.2.0 → pyopenssl-26.4.0}/doc/ChangeLog_old.txt +0 -0
- {pyopenssl-26.2.0 → pyopenssl-26.4.0}/doc/Makefile +0 -0
- {pyopenssl-26.2.0 → pyopenssl-26.4.0}/doc/Quotes +0 -0
- {pyopenssl-26.2.0 → pyopenssl-26.4.0}/doc/README +0 -0
- {pyopenssl-26.2.0 → pyopenssl-26.4.0}/doc/api/ssl.rst +0 -0
- {pyopenssl-26.2.0 → pyopenssl-26.4.0}/doc/api.rst +0 -0
- {pyopenssl-26.2.0 → pyopenssl-26.4.0}/doc/backward-compatibility.rst +0 -0
- {pyopenssl-26.2.0 → pyopenssl-26.4.0}/doc/changelog.rst +0 -0
- {pyopenssl-26.2.0 → pyopenssl-26.4.0}/doc/conf.py +0 -0
- {pyopenssl-26.2.0 → pyopenssl-26.4.0}/doc/images/pyopenssl-brand.png +0 -0
- {pyopenssl-26.2.0 → pyopenssl-26.4.0}/doc/images/pyopenssl-icon.png +0 -0
- {pyopenssl-26.2.0 → pyopenssl-26.4.0}/doc/images/pyopenssl-logo.png +0 -0
- {pyopenssl-26.2.0 → pyopenssl-26.4.0}/doc/images/pyopenssl.svg +0 -0
- {pyopenssl-26.2.0 → pyopenssl-26.4.0}/doc/index.rst +0 -0
- {pyopenssl-26.2.0 → pyopenssl-26.4.0}/doc/install.rst +0 -0
- {pyopenssl-26.2.0 → pyopenssl-26.4.0}/doc/internals.rst +0 -0
- {pyopenssl-26.2.0 → pyopenssl-26.4.0}/doc/make.bat +0 -0
- {pyopenssl-26.2.0 → pyopenssl-26.4.0}/pyproject.toml +0 -0
- {pyopenssl-26.2.0 → pyopenssl-26.4.0}/setup.cfg +0 -0
- {pyopenssl-26.2.0 → pyopenssl-26.4.0}/src/OpenSSL/__init__.py +0 -0
- {pyopenssl-26.2.0 → pyopenssl-26.4.0}/src/OpenSSL/debug.py +0 -0
- {pyopenssl-26.2.0 → pyopenssl-26.4.0}/src/OpenSSL/py.typed +0 -0
- {pyopenssl-26.2.0 → pyopenssl-26.4.0}/src/OpenSSL/rand.py +0 -0
- {pyopenssl-26.2.0 → pyopenssl-26.4.0}/src/pyOpenSSL.egg-info/SOURCES.txt +0 -0
- {pyopenssl-26.2.0 → pyopenssl-26.4.0}/src/pyOpenSSL.egg-info/dependency_links.txt +0 -0
- {pyopenssl-26.2.0 → pyopenssl-26.4.0}/src/pyOpenSSL.egg-info/top_level.txt +0 -0
- {pyopenssl-26.2.0 → pyopenssl-26.4.0}/tests/__init__.py +0 -0
- {pyopenssl-26.2.0 → pyopenssl-26.4.0}/tests/conftest.py +0 -0
- {pyopenssl-26.2.0 → pyopenssl-26.4.0}/tests/test_debug.py +0 -0
- {pyopenssl-26.2.0 → pyopenssl-26.4.0}/tests/test_rand.py +0 -0
- {pyopenssl-26.2.0 → pyopenssl-26.4.0}/tests/test_util.py +0 -0
- {pyopenssl-26.2.0 → pyopenssl-26.4.0}/tests/util.py +0 -0
|
@@ -4,6 +4,47 @@ 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.4.0 (2026-08-01)
|
|
8
|
+
-------------------
|
|
9
|
+
|
|
10
|
+
Backward-incompatible changes:
|
|
11
|
+
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
|
|
12
|
+
|
|
13
|
+
Deprecations:
|
|
14
|
+
^^^^^^^^^^^^^
|
|
15
|
+
|
|
16
|
+
Changes:
|
|
17
|
+
^^^^^^^^
|
|
18
|
+
|
|
19
|
+
- Maximum supported ``cryptography`` version is now 50.x.
|
|
20
|
+
|
|
21
|
+
|
|
22
|
+
26.3.0 (2026-06-12)
|
|
23
|
+
-------------------
|
|
24
|
+
|
|
25
|
+
Backward-incompatible changes:
|
|
26
|
+
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
|
|
27
|
+
|
|
28
|
+
- Dropped support for Python 3.8.
|
|
29
|
+
- The minimum ``cryptography`` version is now 49.0.0.
|
|
30
|
+
- Removed deprecated ``OpenSSL.crypto.X509Req``, ``OpenSSL.crypto.dump_certificate_request``, and ``OpenSSL.crypto.load_certificate_request``. ``cryptography.x509`` should be used instead.
|
|
31
|
+
- ``OpenSSL.SSL.Connection.set_session`` now raises ``ValueError`` if the ``Session`` was obtained from a ``Connection`` that was using a different ``Context`` than this one. OpenSSL requires (but does not verify) that sessions only be re-used with a compatible ``SSL_CTX``, so this contract is now enforced.
|
|
32
|
+
|
|
33
|
+
Deprecations:
|
|
34
|
+
^^^^^^^^^^^^^
|
|
35
|
+
|
|
36
|
+
- Deprecated ``OpenSSL.crypto.PKey.generate_key`` and ``OpenSSL.crypto.PKey.check``. The key generation and loading APIs in ``cryptography`` should be used instead.
|
|
37
|
+
- Deprecated ``OpenSSL.crypto.dump_privatekey``. The serialization APIs on ``cryptography`` private key types should be used instead.
|
|
38
|
+
- Deprecated all the mutable APIs on ``OpenSSL.crypto.X509``: ``set_version``, ``set_pubkey``, ``sign``, ``set_serial_number``, ``gmtime_adj_notAfter``, ``gmtime_adj_notBefore``, ``set_notBefore``, ``set_notAfter``, ``set_issuer``, and ``set_subject``. ``cryptography.x509.CertificateBuilder`` should be used instead.
|
|
39
|
+
- Deprecated ``OpenSSL.SSL.Context.set_passwd_cb``. Users should decrypt and load their private keys themselves, with ``cryptography``'s key loading APIs, and then call ``OpenSSL.SSL.Context.use_privatekey``.
|
|
40
|
+
- Deprecated ``OpenSSL.crypto.X509Name``, as well as the remaining APIs that consume or return it: ``OpenSSL.crypto.X509.get_issuer``, ``OpenSSL.crypto.X509.get_subject``, and ``OpenSSL.SSL.Context.set_client_ca_list``. The APIs in ``cryptography.x509`` should be used instead.
|
|
41
|
+
|
|
42
|
+
Changes:
|
|
43
|
+
^^^^^^^^
|
|
44
|
+
|
|
45
|
+
- ``OpenSSL.SSL.Connection.get_client_ca_list`` now takes an ``as_cryptography`` keyword-argument. When ``True`` is passed then ``cryptography.x509.Name`` are returned, instead of ``OpenSSL.crypto.X509Name``. In the future, passing ``False`` (the default) will be deprecated.
|
|
46
|
+
|
|
47
|
+
|
|
7
48
|
26.2.0 (2026-05-04)
|
|
8
49
|
-------------------
|
|
9
50
|
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
Metadata-Version: 2.4
|
|
2
2
|
Name: pyOpenSSL
|
|
3
|
-
Version: 26.
|
|
3
|
+
Version: 26.4.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.8
|
|
18
17
|
Classifier: Programming Language :: Python :: 3.9
|
|
19
18
|
Classifier: Programming Language :: Python :: 3.10
|
|
20
19
|
Classifier: Programming Language :: Python :: 3.11
|
|
@@ -25,10 +24,10 @@ Classifier: Programming Language :: Python :: Implementation :: PyPy
|
|
|
25
24
|
Classifier: Topic :: Security :: Cryptography
|
|
26
25
|
Classifier: Topic :: Software Development :: Libraries :: Python Modules
|
|
27
26
|
Classifier: Topic :: System :: Networking
|
|
28
|
-
Requires-Python: >=3.
|
|
27
|
+
Requires-Python: >=3.9
|
|
29
28
|
License-File: LICENSE
|
|
30
|
-
Requires-Dist: cryptography<49
|
|
31
|
-
Requires-Dist: typing-extensions>=4.9; python_version < "3.13"
|
|
29
|
+
Requires-Dist: cryptography<51,>=49.0.0
|
|
30
|
+
Requires-Dist: typing-extensions>=4.9; python_version < "3.13"
|
|
32
31
|
Provides-Extra: test
|
|
33
32
|
Requires-Dist: pytest-rerunfailures; extra == "test"
|
|
34
33
|
Requires-Dist: pretend; extra == "test"
|
|
@@ -96,6 +95,47 @@ You can also join ``#pyca`` on ``irc.libera.chat`` to ask questions or get invol
|
|
|
96
95
|
Release Information
|
|
97
96
|
===================
|
|
98
97
|
|
|
98
|
+
26.4.0 (2026-08-01)
|
|
99
|
+
-------------------
|
|
100
|
+
|
|
101
|
+
Backward-incompatible changes:
|
|
102
|
+
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
|
|
103
|
+
|
|
104
|
+
Deprecations:
|
|
105
|
+
^^^^^^^^^^^^^
|
|
106
|
+
|
|
107
|
+
Changes:
|
|
108
|
+
^^^^^^^^
|
|
109
|
+
|
|
110
|
+
- Maximum supported ``cryptography`` version is now 50.x.
|
|
111
|
+
|
|
112
|
+
|
|
113
|
+
26.3.0 (2026-06-12)
|
|
114
|
+
-------------------
|
|
115
|
+
|
|
116
|
+
Backward-incompatible changes:
|
|
117
|
+
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
|
|
118
|
+
|
|
119
|
+
- Dropped support for Python 3.8.
|
|
120
|
+
- The minimum ``cryptography`` version is now 49.0.0.
|
|
121
|
+
- Removed deprecated ``OpenSSL.crypto.X509Req``, ``OpenSSL.crypto.dump_certificate_request``, and ``OpenSSL.crypto.load_certificate_request``. ``cryptography.x509`` should be used instead.
|
|
122
|
+
- ``OpenSSL.SSL.Connection.set_session`` now raises ``ValueError`` if the ``Session`` was obtained from a ``Connection`` that was using a different ``Context`` than this one. OpenSSL requires (but does not verify) that sessions only be re-used with a compatible ``SSL_CTX``, so this contract is now enforced.
|
|
123
|
+
|
|
124
|
+
Deprecations:
|
|
125
|
+
^^^^^^^^^^^^^
|
|
126
|
+
|
|
127
|
+
- Deprecated ``OpenSSL.crypto.PKey.generate_key`` and ``OpenSSL.crypto.PKey.check``. The key generation and loading APIs in ``cryptography`` should be used instead.
|
|
128
|
+
- Deprecated ``OpenSSL.crypto.dump_privatekey``. The serialization APIs on ``cryptography`` private key types should be used instead.
|
|
129
|
+
- Deprecated all the mutable APIs on ``OpenSSL.crypto.X509``: ``set_version``, ``set_pubkey``, ``sign``, ``set_serial_number``, ``gmtime_adj_notAfter``, ``gmtime_adj_notBefore``, ``set_notBefore``, ``set_notAfter``, ``set_issuer``, and ``set_subject``. ``cryptography.x509.CertificateBuilder`` should be used instead.
|
|
130
|
+
- Deprecated ``OpenSSL.SSL.Context.set_passwd_cb``. Users should decrypt and load their private keys themselves, with ``cryptography``'s key loading APIs, and then call ``OpenSSL.SSL.Context.use_privatekey``.
|
|
131
|
+
- Deprecated ``OpenSSL.crypto.X509Name``, as well as the remaining APIs that consume or return it: ``OpenSSL.crypto.X509.get_issuer``, ``OpenSSL.crypto.X509.get_subject``, and ``OpenSSL.SSL.Context.set_client_ca_list``. The APIs in ``cryptography.x509`` should be used instead.
|
|
132
|
+
|
|
133
|
+
Changes:
|
|
134
|
+
^^^^^^^^
|
|
135
|
+
|
|
136
|
+
- ``OpenSSL.SSL.Connection.get_client_ca_list`` now takes an ``as_cryptography`` keyword-argument. When ``True`` is passed then ``cryptography.x509.Name`` are returned, instead of ``OpenSSL.crypto.X509Name``. In the future, passing ``False`` (the default) will be deprecated.
|
|
137
|
+
|
|
138
|
+
|
|
99
139
|
26.2.0 (2026-05-04)
|
|
100
140
|
-------------------
|
|
101
141
|
|
|
@@ -12,7 +12,7 @@
|
|
|
12
12
|
|
|
13
13
|
`pyca/cryptography`_ is likely a better choice than using this module.
|
|
14
14
|
It contains a complete set of cryptographic primitives as well as a significantly better and more powerful X509 API.
|
|
15
|
-
If necessary you can convert to and from cryptography objects using the ``to_cryptography`` and ``from_cryptography`` methods on ``X509``, ``
|
|
15
|
+
If necessary you can convert to and from cryptography objects using the ``to_cryptography`` and ``from_cryptography`` methods on ``X509``, ``CRL``, and ``PKey``.
|
|
16
16
|
|
|
17
17
|
|
|
18
18
|
Elliptic curves
|
|
@@ -42,13 +42,6 @@ Certificates
|
|
|
42
42
|
|
|
43
43
|
.. autofunction:: load_certificate
|
|
44
44
|
|
|
45
|
-
Certificate signing requests
|
|
46
|
-
~~~~~~~~~~~~~~~~~~~~~~~~~~~~
|
|
47
|
-
|
|
48
|
-
.. autofunction:: dump_certificate_request
|
|
49
|
-
|
|
50
|
-
.. autofunction:: load_certificate_request
|
|
51
|
-
|
|
52
45
|
Private keys
|
|
53
46
|
~~~~~~~~~~~~
|
|
54
47
|
|
|
@@ -82,16 +75,6 @@ X509Name objects
|
|
|
82
75
|
:special-members:
|
|
83
76
|
:exclude-members: __repr__, __getattr__, __weakref__
|
|
84
77
|
|
|
85
|
-
.. _openssl-x509req:
|
|
86
|
-
|
|
87
|
-
X509Req objects
|
|
88
|
-
---------------
|
|
89
|
-
|
|
90
|
-
.. autoclass:: X509Req
|
|
91
|
-
:members:
|
|
92
|
-
:special-members:
|
|
93
|
-
:exclude-members: __weakref__
|
|
94
|
-
|
|
95
78
|
.. _openssl-x509store:
|
|
96
79
|
|
|
97
80
|
X509Store objects
|
|
@@ -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.9+ and PyPy_.
|
|
18
18
|
|
|
19
19
|
|
|
20
20
|
Development
|
|
@@ -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.8",
|
|
81
80
|
"Programming Language :: Python :: 3.9",
|
|
82
81
|
"Programming Language :: Python :: 3.10",
|
|
83
82
|
"Programming Language :: Python :: 3.11",
|
|
@@ -89,15 +88,12 @@ if __name__ == "__main__":
|
|
|
89
88
|
"Topic :: Software Development :: Libraries :: Python Modules",
|
|
90
89
|
"Topic :: System :: Networking",
|
|
91
90
|
],
|
|
92
|
-
python_requires=">=3.
|
|
91
|
+
python_requires=">=3.9",
|
|
93
92
|
packages=find_packages(where="src"),
|
|
94
93
|
package_dir={"": "src"},
|
|
95
94
|
install_requires=[
|
|
96
|
-
"cryptography>=
|
|
97
|
-
|
|
98
|
-
"typing-extensions>=4.9; "
|
|
99
|
-
"python_version < '3.13' and python_version >= '3.8'"
|
|
100
|
-
),
|
|
95
|
+
"cryptography>=49.0.0,<51",
|
|
96
|
+
"typing-extensions>=4.9; python_version < '3.13'",
|
|
101
97
|
],
|
|
102
98
|
extras_require={
|
|
103
99
|
"test": ["pytest-rerunfailures", "pretend", "pytest>=3.0.1"],
|
|
@@ -13,6 +13,11 @@ from sys import platform
|
|
|
13
13
|
from typing import Any, Callable, Optional, TypeVar
|
|
14
14
|
from weakref import WeakValueDictionary
|
|
15
15
|
|
|
16
|
+
if sys.version_info >= (3, 13):
|
|
17
|
+
from warnings import deprecated
|
|
18
|
+
else:
|
|
19
|
+
from typing_extensions import deprecated
|
|
20
|
+
|
|
16
21
|
from cryptography import x509
|
|
17
22
|
from cryptography.hazmat.primitives.asymmetric import ec
|
|
18
23
|
|
|
@@ -847,6 +852,11 @@ class Session:
|
|
|
847
852
|
"""
|
|
848
853
|
|
|
849
854
|
_session: Any
|
|
855
|
+
# The Context the Connection this Session came from was using. OpenSSL
|
|
856
|
+
# requires that a session only be re-used with a compatible SSL_CTX, but
|
|
857
|
+
# doesn't verify it, so we pin the Context here and enforce identity in
|
|
858
|
+
# Connection.set_session.
|
|
859
|
+
_context: Context
|
|
850
860
|
|
|
851
861
|
|
|
852
862
|
F = TypeVar("F", bound=Callable[..., Any])
|
|
@@ -1016,6 +1026,11 @@ class Context:
|
|
|
1016
1026
|
FILETYPE_PEM, wrapper, more_args=True, truncate=True
|
|
1017
1027
|
)
|
|
1018
1028
|
|
|
1029
|
+
@deprecated(
|
|
1030
|
+
"Context.set_passwd_cb is deprecated. You should decrypt and load "
|
|
1031
|
+
"your private key yourself, with cryptography's key loading APIs, "
|
|
1032
|
+
"and then use Context.use_privatekey instead."
|
|
1033
|
+
)
|
|
1019
1034
|
@_require_not_used
|
|
1020
1035
|
def set_passwd_cb(
|
|
1021
1036
|
self,
|
|
@@ -1527,6 +1542,10 @@ class Context:
|
|
|
1527
1542
|
_lib.SSL_CTX_set_ciphersuites(self._context, ciphersuites) == 1
|
|
1528
1543
|
)
|
|
1529
1544
|
|
|
1545
|
+
@deprecated(
|
|
1546
|
+
"Context.set_client_ca_list is deprecated. X509Name support in "
|
|
1547
|
+
"pyOpenSSL is deprecated."
|
|
1548
|
+
)
|
|
1530
1549
|
@_require_not_used
|
|
1531
1550
|
def set_client_ca_list(
|
|
1532
1551
|
self, certificate_authorities: Sequence[X509Name]
|
|
@@ -2628,10 +2647,30 @@ class Connection:
|
|
|
2628
2647
|
ciphers.append(_ffi.string(result).decode("utf-8"))
|
|
2629
2648
|
return ciphers
|
|
2630
2649
|
|
|
2631
|
-
|
|
2650
|
+
@typing.overload
|
|
2651
|
+
def get_client_ca_list(
|
|
2652
|
+
self, *, as_cryptography: typing.Literal[True]
|
|
2653
|
+
) -> list[x509.Name]:
|
|
2654
|
+
pass
|
|
2655
|
+
|
|
2656
|
+
@typing.overload
|
|
2657
|
+
def get_client_ca_list(
|
|
2658
|
+
self, *, as_cryptography: typing.Literal[False] = False
|
|
2659
|
+
) -> list[X509Name]:
|
|
2660
|
+
pass
|
|
2661
|
+
|
|
2662
|
+
def get_client_ca_list(
|
|
2663
|
+
self,
|
|
2664
|
+
*,
|
|
2665
|
+
as_cryptography: typing.Literal[True] | typing.Literal[False] = False,
|
|
2666
|
+
) -> list[X509Name] | list[x509.Name]:
|
|
2632
2667
|
"""
|
|
2633
2668
|
Get CAs whose certificates are suggested for client authentication.
|
|
2634
2669
|
|
|
2670
|
+
:param bool as_cryptography: Controls whether a list of
|
|
2671
|
+
``cryptography.x509.Name`` or ``OpenSSL.crypto.X509Name``
|
|
2672
|
+
objects should be returned.
|
|
2673
|
+
|
|
2635
2674
|
:return: If this is a server connection, the list of certificate
|
|
2636
2675
|
authorities that will be sent or has been sent to the client, as
|
|
2637
2676
|
controlled by this :class:`Connection`'s :class:`Context`.
|
|
@@ -2646,13 +2685,28 @@ class Connection:
|
|
|
2646
2685
|
# TODO: This is untested.
|
|
2647
2686
|
return []
|
|
2648
2687
|
|
|
2688
|
+
if as_cryptography:
|
|
2689
|
+
names = []
|
|
2690
|
+
for i in range(_lib.sk_X509_NAME_num(ca_names)):
|
|
2691
|
+
name = _lib.sk_X509_NAME_value(ca_names, i)
|
|
2692
|
+
result_buffer = _ffi.new("unsigned char**")
|
|
2693
|
+
encode_result = _lib.i2d_X509_NAME(name, result_buffer)
|
|
2694
|
+
_openssl_assert(encode_result >= 0)
|
|
2695
|
+
der = _ffi.buffer(result_buffer[0], encode_result)[:]
|
|
2696
|
+
_lib.OPENSSL_free(result_buffer[0])
|
|
2697
|
+
|
|
2698
|
+
names.append(x509.Name.from_bytes(der))
|
|
2699
|
+
return names
|
|
2700
|
+
|
|
2649
2701
|
result = []
|
|
2650
2702
|
for i in range(_lib.sk_X509_NAME_num(ca_names)):
|
|
2651
2703
|
name = _lib.sk_X509_NAME_value(ca_names, i)
|
|
2652
2704
|
copy = _lib.X509_NAME_dup(name)
|
|
2653
2705
|
_openssl_assert(copy != _ffi.NULL)
|
|
2654
2706
|
|
|
2655
|
-
|
|
2707
|
+
# Bypass X509Name.__new__, which warns that X509Name is
|
|
2708
|
+
# deprecated -- this method is not itself deprecated.
|
|
2709
|
+
pyname = object.__new__(X509Name)
|
|
2656
2710
|
pyname._name = _ffi.gc(copy, _lib.X509_NAME_free)
|
|
2657
2711
|
result.append(pyname)
|
|
2658
2712
|
return result
|
|
@@ -3032,12 +3086,18 @@ class Connection:
|
|
|
3032
3086
|
|
|
3033
3087
|
pysession = Session.__new__(Session)
|
|
3034
3088
|
pysession._session = _ffi.gc(session, _lib.SSL_SESSION_free)
|
|
3089
|
+
pysession._context = self._context
|
|
3035
3090
|
return pysession
|
|
3036
3091
|
|
|
3037
3092
|
def set_session(self, session: Session) -> None:
|
|
3038
3093
|
"""
|
|
3039
3094
|
Set the session to be used when the TLS/SSL connection is established.
|
|
3040
3095
|
|
|
3096
|
+
The session must have been obtained, via :meth:`get_session`, from a
|
|
3097
|
+
:class:`Connection` that was using the same :class:`Context` as this
|
|
3098
|
+
one. OpenSSL requires (but does not verify) that sessions only be
|
|
3099
|
+
re-used with a compatible ``SSL_CTX``, so this is enforced here.
|
|
3100
|
+
|
|
3041
3101
|
:param session: A Session instance representing the session to use.
|
|
3042
3102
|
:returns: None
|
|
3043
3103
|
|
|
@@ -3046,6 +3106,12 @@ class Connection:
|
|
|
3046
3106
|
if not isinstance(session, Session):
|
|
3047
3107
|
raise TypeError("session must be a Session instance")
|
|
3048
3108
|
|
|
3109
|
+
if session._context is not self._context:
|
|
3110
|
+
raise ValueError(
|
|
3111
|
+
"session must have been created by a Connection using the "
|
|
3112
|
+
"same Context as this one"
|
|
3113
|
+
)
|
|
3114
|
+
|
|
3049
3115
|
result = _lib.SSL_set_session(self._ssl, session._session)
|
|
3050
3116
|
_openssl_assert(result == 1)
|
|
3051
3117
|
|
|
@@ -7,10 +7,7 @@ from typing import Any, Callable, NoReturn, Union
|
|
|
7
7
|
|
|
8
8
|
from cryptography.hazmat.bindings.openssl.binding import Binding
|
|
9
9
|
|
|
10
|
-
|
|
11
|
-
StrOrBytesPath = Union[str, bytes, os.PathLike[str], os.PathLike[bytes]]
|
|
12
|
-
else:
|
|
13
|
-
StrOrBytesPath = Union[str, bytes, os.PathLike]
|
|
10
|
+
StrOrBytesPath = Union[str, bytes, os.PathLike[str], os.PathLike[bytes]]
|
|
14
11
|
|
|
15
12
|
binding = Binding()
|
|
16
13
|
ffi = binding.ffi
|