add_extensions removed in pyopenssl 26.4.0
In our sandbox runs up to 2026-10-27, gpt-6.1-sol wrote certificate.add_extensions([ for pyopenssl. It fails on 26.4.0 with AttributeError (changed between 26.0.0 and 26.4.0). Use .add_extension( instead.
- What to do
- replace the line
- Output
- same on one example
- Patch
- syntax error when applied word for word
- Auto-apply
- not allowed
- Seen in
- 1 model
- Worked / failed
- 2 / 0
- Last verified
- 2026-10-27
What to do
Not for automatic application — applied word for word, the patch does not parse: SyntaxError: closing parenthesis ']' does not match opening parenthesis '(' on line 17 (line 23). Show this correction to the user as a lead. Replace the old line with the new one; the rest of the code can stay.
Automatic application: not allowed — the patch gives syntax_error when applied word for word. Automatic application is allowed only when proof.equivalent is true and proof.applicability.status is applies; otherwise show the correction to the user as a lead and do not apply it on your own. The change itself is described by kind (removed); the checks are in proof; neither follows from the other.
How to tell this applies to your code
- pyopenssl version 26.4.0 or newer is installed (checked on 26.4.0; changed between 26.0.0 and 26.4.0).
- Your code uses:
certificate.add_extensions - Or it already failed with:
AttributeError: 'X509' object has no attribute 'add_extensions'(every correction for this error)
Old and new code
certificate.add_extensions([.add_extension(
Error on 26.4.0:
AttributeError: 'X509' object has no attribute 'add_extensions'
Other verified fixes
The fix above passed 1 time. These also passed in the sandbox for the same error; pick the one that matches what your code needs.
No direct replacement · passed 1 time · gpt-6.1-sol · patch: nothing to apply word for word
cert.add_extensions([No direct replacement: drop this use.
Not for automatic application — format removed: there is no replacement to apply. Show this correction to the user as a lead. add_extensions is not available in pyopenssl 26.4.0; remove or replace this use. The same code works on pyopenssl 26.0.0: pin a version before 26.4.0 if you cannot change the code. Release notes: builder = builder.add_extension(x509.BasicConstraints(ca=False, path_length=None), critical=True)
Alternatives are leads for the user, not for automatic application: Automatic application is allowed only when proof.equivalent is true and proof.applicability.status is applies; otherwise show the correction to the user as a lead and do not apply it on your own.
| Script | pyopenssl version | Result |
|---|---|---|
| Code the models wrote | 26.0.0 | works |
| Code the models wrote | 26.4.0 | fails: AttributeError |
| Verified example below | 26.4.0 | works |
| Output of the verified example | 26.4.0 | same as the original's on 26.0.0 (observed stdout of one example; not a proof of equivalent behaviour) |
| Patch applied word for word to the example | 26.4.0 | APPLIED WORD FOR WORD, THE PATCH DOES NOT PARSE — applied word for word, the patch does not parse: SyntaxError: closing parenthesis ']' does not match opening parenthesis '(' on line 17 (line 23) |
Verified example for pyopenssl 26.4.0
from datetime import datetime, timedelta, timezone
from cryptography import x509
from cryptography.hazmat.primitives import hashes
from cryptography.x509.oid import NameOID
from OpenSSL import crypto
def format_extension_value(value):
if isinstance(value, x509.BasicConstraints):
text = "CA:TRUE" if value.ca else "CA:FALSE"
if value.path_length is not None:
text += f", pathlen:{value.path_length}"
return text
return str(value)
def main():
key = crypto.PKey()
key.generate_key(crypto.TYPE_RSA, 2048)
private_key = key.to_cryptography_key()
subject = x509.Name([x509.NameAttribute(NameOID.COMMON_NAME, "test.local")])
now = datetime.now(timezone.utc)
builder = (
x509.CertificateBuilder() # X.509 v3 by default
.serial_number(1)
.subject_name(subject)
.issuer_name(subject)
.public_key(private_key.public_key())
.not_valid_before(now)
.not_valid_after(now + timedelta(seconds=365 * 24 * 60 * 60))
.add_extension(
x509.BasicConstraints(ca=False, path_length=None),
critical=True,
)
)
signed = builder.sign(private_key, hashes.SHA256())
certificate = crypto.X509.from_cryptography(signed)
print(f"Subject CN: {certificate.get_subject().CN}")
for extension in signed.extensions:
name = extension.oid._name
print(f"{name}: {format_extension_value(extension.value)}")
if __name__ == "__main__":
main()Source
Removed deprecated ``OpenSSL.crypto.X509Extension``, ``OpenSSL.crypto.X509Req.add_extension``, ``OpenSSL.crypto.X509Req.get_extensions``, ``OpenSSL.crypto.X509.add_extension``, ``OpenSSL.crypto.X509.get_extensions``. ``cryptography.x509`` should be used instead.
Release notes · Seen in: gpt-6.1-sol · First seen 2026-10-23 · Last verified 2026-10-27 · All corrections for pyopenssl
For agents
- This page as JSON:
https://formachines.ai/errata/pypi/pyopenssl/0003-openssl-crypto-x509extension/index.json - Whole database in plain text:
/errata/llms-full.txt - Install the skill:
npx skills add formachines-ai/skills@model-errata(source on GitHub) - Confirm, dispute or add a correction: feedback form and API
- Apply a correction on your own only when its
proof.auto_applyis true (Automatic application is allowed only when proof.equivalent is true and proof.applicability.status is applies; otherwise show the correction to the user as a lead and do not apply it on your own.)