Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
15 changes: 15 additions & 0 deletions CHANGELOG.rst
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,21 @@ Changelog
Versions are year-based with a strict backward-compatibility policy.
The third digit is only for regressions.

26.3.0 (UNRELEASED)
-------------------

Backward-incompatible changes:
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

Deprecations:
^^^^^^^^^^^^^

- Deprecated ``OpenSSL.crypto.PKey.generate_key`` and ``OpenSSL.crypto.PKey.check``. The key generation and loading APIs in ``cryptography`` should be used instead.
- Deprecated ``OpenSSL.crypto.dump_privatekey``. The serialization APIs on ``cryptography`` private key types should be used instead.

Changes:
^^^^^^^^

26.2.0 (2026-05-04)
-------------------

Expand Down
28 changes: 27 additions & 1 deletion src/OpenSSL/crypto.py
Original file line number Diff line number Diff line change
Expand Up @@ -275,7 +275,7 @@ def to_cryptography_key(self) -> _Key:
der = dump_publickey(FILETYPE_ASN1, self)
return typing.cast(_Key, load_der_public_key(der))
else:
der = dump_privatekey(FILETYPE_ASN1, self)
der = _dump_privatekey_internal(FILETYPE_ASN1, self)
return typing.cast(_Key, load_der_private_key(der, password=None))

@classmethod
Expand Down Expand Up @@ -336,6 +336,10 @@ def from_cryptography_key(cls, crypto_key: _Key) -> PKey:
)
return load_privatekey(FILETYPE_ASN1, der)

@deprecated(
"PKey.generate_key is deprecated. You should use the key "
"generation APIs in cryptography instead."
)
def generate_key(self, type: int, bits: int) -> None:
"""
Generate a key pair of the given type, with the given number of bits.
Expand Down Expand Up @@ -392,6 +396,10 @@ def generate_key(self, type: int, bits: int) -> None:

self._initialized = True

@deprecated(
"PKey.check is deprecated. You should use the APIs in "
"cryptography instead."
)
def check(self) -> bool:
"""
Check the consistency of an RSA private key.
Expand Down Expand Up @@ -1851,6 +1859,10 @@ def dump_privatekey(

:return: The buffer with the dumped key in
:rtype: bytes

.. deprecated:: 26.3.0
Use the serialization APIs on ``cryptography`` private key types
instead.
"""
bio = _new_mem_buf()

Expand Down Expand Up @@ -1900,6 +1912,20 @@ def dump_privatekey(
return _bio_to_string(bio)


_dump_privatekey_internal = dump_privatekey

utils.deprecated(
dump_privatekey,
__name__,
(
"dump_privatekey is deprecated. You should use the APIs in "
"cryptography."
),
DeprecationWarning,
name="dump_privatekey",
)


class _PassphraseHelper:
def __init__(
self,
Expand Down
Loading