cryptography 50.0.0 and 51.0.0 breaking changes, tested
Updated December 3, 2026
On this page
What breaks when you upgrade to cryptography 50 or 51?
For most code, nothing breaks: the big changes in 50.0.0 and 51.0.0 are deprecations, and a deprecation in cryptography prints a warning and keeps working. What can raise an error is narrower: code that builds empty X.509 extensions, code that passes overlapping buffers to an *_into method, certificate verification given an IP address as a DNS name, and stricter parsing of malformed certificates, CRLs and keys.
If you're coming from 48.x, you also cross 49.0.0, which is the release with real removals. Here's the short list, read from the cryptography changelog on December 3, 2026:
| Version | Change | What you see |
|---|---|---|
| 49.0.0 (June 12, 2026) | PUBLIC_KEY_TYPES and four other type aliases removed | AttributeError |
| 49.0.0 | No x86_64 macOS or 32-bit Windows wheels | pip builds from source, which needs Rust |
| 49.0.0 | ChaCha20 tracks its 32-bit block counter | ValueError past the counter's limit |
| 49.0.0 | Certificates with NULL ECDSA or DSA signature parameters | ValueError on load |
| 50.0.0 (July 31, 2026) | Finite-field Diffie-Hellman (FFDH) deprecated | CryptographyDeprecationWarning |
| 50.0.0 | Stricter DER: SCT lists, BIT STRING unused bits, CRL dates, OCSP version | ValueError on malformed input |
| 51.0.0 (December 1, 2026) | DSA deprecated | CryptographyDeprecationWarning |
| 51.0.0 | Empty SubjectAlternativeName, IssuerAlternativeName, ExtendedKeyUsage or CertificatePolicies | ValueError |
| 51.0.0 | *_into methods with overlapping input and output | ValueError |
| 51.0.0 | build_server_verifier given an IP address as a DNSName | ValueError |
Python support didn't change across these releases: all four list requires_python as 3.9 or later (excluding 3.9.0 and 3.9.1) on PyPI. If you're still on 3.9, that's its own problem: the Python release calendar has its end-of-life date.
What does each version actually do?
I ran the same script against 48.0.1, 49.0.0, 50.0.0 and 51.0.0, each in its own virtual environment, on December 3, 2026 with Python 3.12.15. It calls six things that changed and prints whether each one worked, raised, or warned.
import warnings
import cryptography
from cryptography import x509
from cryptography.hazmat.primitives.asymmetric import (
dh, dsa, types)
from cryptography.hazmat.primitives.ciphers import (
Cipher, algorithms, modes)
def run(name, fn):
with warnings.catch_warnings(record=True) as w:
warnings.simplefilter("always")
try:
fn()
out = "ok"
except Exception as e:
out = f"{type(e).__name__}: {e}"
for x in w:
out += f" [{x.category.__name__}]"
print(f"{name}: {out}")
def chacha():
nonce = b"\xff" * 4 + b"\x00" * 12
alg = algorithms.ChaCha20(b"k" * 32, nonce)
Cipher(alg, None).encryptor().update(b"x" * 128)
def overlap():
ctr = modes.CTR(b"\x00" * 16)
enc = Cipher(algorithms.AES(b"k" * 16), ctr)
buf = bytearray(32)
view = memoryview(buf)[:16]
enc.encryptor().update_into(view, buf)
print("cryptography", cryptography.__version__)
run("PUBLIC_KEY_TYPES", lambda: types.PUBLIC_KEY_TYPES)
run("dh", lambda: dh.generate_parameters(2, 512))
run("dsa", lambda: dsa.generate_private_key(1024))
run("empty SAN", lambda: x509.SubjectAlternativeName([]))
run("chacha20", chacha)
run("update_into", overlap)Then, for each version (shown for 51.0.0):
python3.12 -m venv v51.0.0
v51.0.0/bin/pip install -q cryptography==51.0.0
v51.0.0/bin/python check.pyOutput on 51.0.0, with the two long error messages wrapped here to fit (each prints as one line):
cryptography 51.0.0
PUBLIC_KEY_TYPES: AttributeError: module
'cryptography.hazmat.primitives.asymmetric.types'
has no attribute 'PUBLIC_KEY_TYPES'
dh: ok [CryptographyDeprecationWarning]
dsa: ok [CryptographyDeprecationWarning]
empty SAN: ValueError: general_names must be a
non-empty list
chacha20: ValueError: Exceeded the maximum number
of bytes that can be encrypted with ChaCha20 for
this nonce. The 32-bit counter portion of the
nonce would overflow.
update_into: ValueError: data and buf must not
overlapAll four versions side by side, from the same run:
| Call | 48.0.1 and 49.0.0 | 50.0.0 and 51.0.0 |
|---|---|---|
types.PUBLIC_KEY_TYPES | 48.0.1: ok, CryptographyDeprecationWarning. 49.0.0: AttributeError | AttributeError |
dh.generate_parameters | ok | ok, CryptographyDeprecationWarning |
dsa.generate_private_key | ok | 50.0.0: ok. 51.0.0: ok, CryptographyDeprecationWarning |
SubjectAlternativeName([]) | ok | 50.0.0: ok. 51.0.0: ValueError |
| ChaCha20 past the counter | 48.0.1: ok. 49.0.0: ValueError | ValueError |
update_into with overlap | ok | 50.0.0: ok. 51.0.0: ValueError |
Two things stand out. The deprecations never stop the program: the DH parameters and the DSA key are still created, just with a warning. And the errors are all for input that was wrong before. An empty subjectAltName breaks RFC 5280, and overlapping buffers could produce wrong output silently, per the 51.0.0 changelog entry.
What did cryptography 49.0.0 remove?
49.0.0 removed five type aliases, two wheel platforms, and two lenient behaviors. It's the release that turns old code into errors, so check it first if you're on 48.x or older. From the 49.0.0 changelog entry:
- The aliases
PUBLIC_KEY_TYPES,PRIVATE_KEY_TYPES,CERTIFICATE_PRIVATE_KEY_TYPES,CERTIFICATE_ISSUER_PUBLIC_KEY_TYPESandCERTIFICATE_PUBLIC_KEY_TYPESare gone. UsePublicKeyTypes,PrivateKeyTypes,CertificateIssuerPrivateKeyTypes,CertificateIssuerPublicKeyTypesandCertificatePublicKeyTypes. They were deprecated in 40.0, so they warned for nine major releases. - No more x86_64 macOS wheels. 48.0.1 shipped
macosx_10_9_universal2wheels; 49.0.0 and later ship onlymacosx_11_0_arm64, per the file lists on PyPI. 32-bit Windows (win32) wheels are gone too. - ChaCha20 now treats the first 4 bytes of the nonce as a 32-bit little-endian block counter, as RFC 7539 defines, and raises ValueError before that counter would overflow. With the counter bytes set to zero you can encrypt up to 256 GiB per nonce, per the changelog.
- Certificates whose ECDSA or DSA signature AlgorithmIdentifier carries encoded NULL parameters now fail to load. The changelog says older Java versions wrote them; before 49.0.0 they loaded with a deprecation warning.
The wheel change is the one that bites CI on Intel Macs. I asked pip for an x86_64 macOS wheel of each version:
pip download cryptography==51.0.0 --no-deps \
--only-binary=:all: --python-version 3.12 \
--platform macosx_11_0_x86_64 -d dlFor 48.0.1 it downloaded cryptography-48.0.1-cp311-abi3-macosx_10_9_universal2.whl. For 51.0.0 it printed ERROR: Could not find a version that satisfies the requirement cryptography==51.0.0, and the version list it printed ends at 48.0.1. Without --only-binary, pip falls back to the source package and needs a Rust toolchain (1.85.0 or newer for 51.0.0, per its changelog). On an Intel Mac you can pin cryptography<49 for now, but you give up the 50.0.0 security fix. Moving that job to an arm64 runner is the better fix.
What changed in cryptography 50.0.0?
50.0.0 fixes a security bug in PKCS#7 decryption, deprecates finite-field Diffie-Hellman, and rejects several kinds of malformed DER that used to load. It was released on July 31, 2026, per PyPI.
The security fix: CVE-2026-69247
pkcs7_decrypt_der and its PEM and S/MIME variants used to return errors or timing that differed when unwrapping a RecipientInfo's encryptedKey. The changelog says that could act as a Bleichenbacher oracle for code that decrypts untrusted messages. 50.0.0 substitutes a random key on failure, as RFC 3218 describes. If you decrypt S/MIME or PKCS#7 from outside, this alone is the reason to upgrade.
FFDH is deprecated
Everything in cryptography.hazmat.primitives.asymmetric.dh, plus loading FFDH keys or parameters, now warns:
CryptographyDeprecationWarning: Diffie-Hellman
over finite fields (FFDH) is deprecated and support
will be removed in a future release. Use a more
modern key exchange algorithm.That's wrapped here; it prints as one line. The usual replacement is X25519 or elliptic-curve Diffie-Hellman (ECDH). Elliptic-curve DH isn't affected: the deprecation covers finite fields only.
Stricter parsing
- Signed Certificate Timestamp lists with trailing bytes are rejected.
- Public keys and EC private keys whose BIT STRING declares non-zero unused bits are rejected.
- A CRL entry's InvalidityDate with fractional seconds or another non-DER time is rejected.
load_der_ocsp_requestandload_der_ocsp_responsereject anything but version v1.- Diffie-Hellman public keys with a modulus under 512 bits are rejected.
Valid input isn't affected. If you parse certificates or OCSP responses from many sources, such as a scanner or a proxy, expect a few that used to load to raise ValueError now.
50.0.0 also made the X.509 verification APIs stable under the project's API stability policy, added the Cobblestone streaming encryption recipe, and lets you compare the built-in hash and padding classes with ==.
What changed in cryptography 51.0.0?
51.0.0 deprecates DSA, turns four kinds of invalid input into ValueError, and moves its wheels to OpenSSL 4.1.1. It was released on December 1, 2026, per the changelog and PyPI.
DSA is deprecated
Every DSA type and loading DSA keys, including from X.509 certificates and CSRs, now warns:
CryptographyDeprecationWarning: DSA is deprecated
and support will be removed in a future release.
Use a more modern signature algorithm.Wrapped again; it's one line. Ed25519 or ECDSA is the usual move. If DSA comes from a certificate you load but don't control, the warning still fires, so you may need to silence it for that call (see the warnings section below).
New ValueErrors
x509.SubjectAlternativeName([]),IssuerAlternativeName([]),ExtendedKeyUsage([])andCertificatePolicies([])raise. Parsing a certificate with an empty subjectAltName or issuerAltName also raises. The fix is to leave the extension out when the list is empty.encrypt_into,update_into,derive_intoand the other*_intomethods raise when the input and output buffers overlap. Use a separate output buffer.PolicyBuilder.build_server_verifierraises when given aDNSNamethat is an IP address. Passx509.IPAddressinstead. Before 51.0.0 a wildcard such as *.0.2.1 matched 192.0.2.1, per the changelog, so this one is a security fix too.EllipticCurvePrivateNumbers.private_key()raises when the private value isn't smaller than the curve's order, and encrypted traditional PEM keys with a wrong DEK-Info IV length raise.- X.509 names reject non-ASCII IA5String values and NumericString values with anything but digits and spaces.
Builds and platforms
- Wheels are built with OpenSSL 4.1.1 (50.0.2 used 4.0.3).
- PyPy 3.11 wheels are gone and PyPy 3.12 wheels are new; PyPy 3.11 still installs from source.
- New Windows arm64 wheels, and abi3t wheels for free-threaded CPython 3.15, appear in the 51.0.0 file list on PyPI.
- The minimum Rust version for source builds is 1.85.0, up from 1.83.0.
- On Python 3.15, CFFI 2.1.1 or newer is required.
It also fixes a deadlock when several threads derive Argon2 keys with lanes greater than 1, which is worth the upgrade on its own if you hash passwords with Argon2id from a thread pool.
Why does pip say pyopenssl requires cryptography<51?
Because pyOpenSSL pins an upper bound on cryptography, and pyOpenSSL 26.4.0 allows only up to, but not including, 51. Upgrade pyOpenSSL to 26.5.1 (released December 2, 2026), which allows 49.0.0 up to 52, per its PyPI metadata. Here's what pip printed when I installed 51.0.0 on top of pyOpenSSL 26.4.0:
ERROR: pip's dependency resolver does not
currently take into account all the packages
that are installed. This behaviour is the source
of the following dependency conflicts.
pyopenssl 26.4.0 requires cryptography<51,>=49.0.0,
but you have cryptography 51.0.0 which is
incompatible.
Successfully installed cryptography-51.0.0That's wrapped to fit. Note the last line: pip installed 51.0.0 anyway, so the conflict is a warning in your logs, not a failed install. A lockfile resolver has to fail instead, because no pyOpenSSL 26.4.0 install allows 51.0.0. The fix is the same either way:
pip install -U "cryptography==51.0.0" \
"pyopenssl==26.5.1"I ran the 26.5.1 pair in a clean environment and pip installed both with no conflict. The pin is deliberate: cryptography's release checklist says each major release comes with a pyOpenSSL release that raises the maximum cryptography version, so a new cryptography major usually needs a new pyOpenSSL.
How do I find and handle the new deprecation warnings?
Search your code for the deprecated modules, then make the warning fail your tests so new uses can't slip in. CryptographyDeprecationWarning is a subclass of UserWarning, not DeprecationWarning, which matters for filters. Start with a search:
grep -rnE "asymmetric import (dsa|dh)|\
asymmetric\.(dsa|dh)" --include='*.py' .Run it on your source folder, not on one that holds a virtualenv: in my test it also matched cryptography's own files and pyOpenSSL's OpenSSL/crypto.py inside the venv. It only finds direct imports. Loading a DSA key from a file or a certificate warns too, with no import to find, so the tests are the better net. In pytest, put this in pytest.ini:
[pytest]
filterwarnings =
error::cryptography.utils.CryptographyDeprecationWarningWith pytest 9.2.0 and cryptography 51.0.0, a test that creates a DSA key then failed with FAILED test_dsa.py::test_sign - cryptography.utils.CryptographyDeprecationWar... (pytest cuts the line itself).
Don't try the same on the python command line. python -W error::cryptography.utils.CryptographyDeprecationWarning prints Invalid -W option ignored: invalid module name: 'cryptography.utils' and carries on, because Python reads -W before any package is imported. Use -W error::UserWarning instead; it raised on the DSA call in my run.
When you can't move off DSA or FFDH yet, silence that one warning by message, not all of them:
import warnings
from cryptography.utils import (
CryptographyDeprecationWarning)
warnings.filterwarnings(
"ignore",
message="DSA is deprecated",
category=CryptographyDeprecationWarning,
)How long do you have? The project's API stability policy says a deprecated feature warns in the next two major releases and is removed or changed in the third, unless the project gives a longer period for a widely used API. By that rule FFDH (warning since 50) could go as early as 52.0.0 and DSA (warning since 51) as early as 53.0.0. That's my reading of the policy, not a published date.
How do I upgrade to cryptography 51 safely?
Upgrade cryptography and pyOpenSSL together, run your tests with the deprecation warning as an error, and fix the errors before the warnings. In order:
- See what depends on it:
pip show cryptographylists the installed packages that require it under Required-by. pyOpenSSL is the one with an upper bound. - Upgrade both:
pip install -U cryptography==51.0.0 pyopenssl==26.5.1, or the same bump in your lockfile. - Search for the removed aliases:
grep -rn "_KEY_TYPES" --include='*.py' .and rename any old upper-case name to its new form. - Run the tests with the pytest filter above. Fix each ValueError first: they are the calls that changed behavior. Then list the warnings you want to migrate and the ones you'll silence for now.
- Check CI runners: Intel macOS and 32-bit Windows jobs have no wheels from 49.0.0 on, so they need Rust or a different runner.
- If you decrypt PKCS#7 or S/MIME from outside, ship at least 50.0.0 now for CVE-2026-69247, even if the DSA and FFDH work waits.
For a general way to diff two versions of any package before you upgrade, see how to find breaking changes between two versions, and for doing it across a whole project, how to check dependencies for breaking changes before upgrading.
Where Since.dev fits
Since.dev keeps a cryptography breaking changes page that lists what each release removed, renamed or changed, each with its source, so a deprecation buried in a long changelog doesn't slip past you. For another Python upgrade tested the same way, see the google-auth 2.56.2 change.
To see what a public repository is exposed to, run a free scan, or give your coding agent the same answers through the docs. When a change like this reaches a repository you connect, Since.dev reports where your code is affected and can open a pull request with the fix for you to review. It doesn't open routine version bumps. Nothing merges or deploys on its own.
Questions
Is cryptography 50.0.0 a breaking change?
Mostly not. It deprecates finite-field Diffie-Hellman, which prints a CryptographyDeprecationWarning and keeps working, and it fixes CVE-2026-69247 in PKCS#7 decryption. What can now raise ValueError is malformed input: SCT lists with trailing bytes, keys with non-zero unused bits, non-DER CRL dates and OCSP data that isn't version v1.
What changed in cryptography 51.0.0?
51.0.0, released December 1, 2026, deprecates DSA and raises ValueError for empty SubjectAlternativeName, IssuerAlternativeName, ExtendedKeyUsage and CertificatePolicies, for overlapping buffers in the *_into methods, and for an IP address passed as a DNSName to build_server_verifier. Its wheels use OpenSSL 4.1.1, and source builds need Rust 1.85.0.
Why do I get AttributeError: no attribute 'PUBLIC_KEY_TYPES'?
cryptography 49.0.0 removed PUBLIC_KEY_TYPES and four other upper-case type aliases that had been deprecated since 40.0. Use PublicKeyTypes, PrivateKeyTypes, CertificateIssuerPrivateKeyTypes, CertificateIssuerPublicKeyTypes and CertificatePublicKeyTypes from cryptography.hazmat.primitives.asymmetric.types instead.
How do I fix pyopenssl requires cryptography below 51?
Upgrade pyOpenSSL to 26.5.1, released December 2, 2026, which accepts cryptography 49.0.0 up to, but not including, 52. pyOpenSSL 26.4.0 stops before 51, so pip prints a dependency conflict when you install cryptography 51.0.0 next to it, and a lockfile resolver can't pick both.
Does cryptography still support Intel Macs?
Not with wheels. From 49.0.0 on, cryptography publishes only arm64 macOS wheels, so pip on an x86_64 Mac builds from source, which needs a Rust toolchain. The last version with an x86_64 macOS wheel is 48.0.1.
How do I silence CryptographyDeprecationWarning for DSA?
Call warnings.filterwarnings with action ignore, message "DSA is deprecated" and category CryptographyDeprecationWarning from cryptography.utils, before the DSA call. Filtering by message keeps every other deprecation visible. Under the project's policy a deprecated feature warns for two major releases before it's removed, so treat the filter as temporary.
Related guides
How-to
- google-auth 2.56.2 breaking change: the service account email check, testedgoogle-auth 2.56.2 only runs the Regional Access Boundary lookup for .gserviceaccount.com emails, and 2.63.0 turns it off by default. Tested on three versions.
- python-multipart 0.0.20 to 0.0.34: what breaks when you upgradeUpgrading python-multipart from 0.0.20 to 0.0.34? Semicolons stop splitting form fields, Python 3.11 is the floor, and two APIs are gone. Tested side by side.
- How to find the breaking changes between two versions of a packageHow to find breaking changes between two versions of a package: list the releases in between, read each changelog, diff the code. Commands for npm, PyPI, Go.
- How to check your dependencies for breaking changes before you upgradeHow to check dependencies for breaking changes before upgrading: the commands, a real failing upgrade, CI that fails on deprecations, and where notices appear.
- boto3 1.44.0 breaking changes: the new retry default, testedboto3 1.44.0 makes standard retries the default: 3 attempts instead of 5, much shorter waits, and bearer tokens need HTTPS. Tested on both versions.

Put your code on continuous maintenance.
Scan a public repository now, or give your agent one line.
See how out of date your code is.
Tell your agent what changed since it was trained.
claude mcp add --transport http since https://api.since.dev/mcpCodex, Cursor and any MCP client use https://api.since.dev/mcp.