public inbox for git-commits@fedoraproject.org
help / color / mirror / Atom feed
To: git-commits@fedoraproject.org
Subject: [rpms/python3.6] f44: Fix ssl.SSLError: [ASN1: NOT_ENOUGH_DATA] not enough data with OpenSSL 3.5.7+
Date: Sun, 05 Jul 2026 20:24:51 GMT [thread overview]
Message-ID: <178328309145.1.10582343655231122092.rpms-python3.6-a566adb37458@fedoraproject.org> (raw)
A new commit has been pushed.
Repo : rpms/python3.6
Branch : f44
Commit : a566adb374583c2130152dba24e9403e7bc6149b
Author : Miro Hrončok <miro@hroncok.cz>
Date : 2026-07-02T11:09:38+02:00
Stats : +91/-1 in 2 file(s)
URL : https://src.fedoraproject.org/rpms/python3.6/c/a566adb374583c2130152dba24e9403e7bc6149b?branch=f44
Log:
Fix ssl.SSLError: [ASN1: NOT_ENOUGH_DATA] not enough data with OpenSSL 3.5.7+
---
diff --git a/00489-openssl-3.5.7.patch b/00489-openssl-3.5.7.patch
new file mode 100644
index 0000000..eea0c4e
--- /dev/null
+++ b/00489-openssl-3.5.7.patch
@@ -0,0 +1,75 @@
+From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
+From: David Benjamin <davidben@google.com>
+Date: Fri, 24 Mar 2023 09:04:30 -0400
+Subject: 00489: Use BIO_eof to detect EOF for SSL_FILETYPE_ASN1
+
+In PEM, we need to parse until error and then suppress `PEM_R_NO_START_LINE`, because PEM allows arbitrary leading and trailing data. DER, however, does not. Parsing until error and suppressing `ASN1_R_HEADER_TOO_LONG` doesn't quite work because that error also covers some cases that should be rejected.
+
+Instead, check `BIO_eof` early and stop the loop that way.
+
+This fixes https://github.com/python/cpython/issues/151504 and adds compatibility with OpenSSL 3.5.7+
+
+(cherry-picked from commit acfe02f3b05436658d92add6b168538b30f357f0)
+---
+ Lib/test/test_ssl.py | 2 ++
+ .../2022-12-20-10-55-14.gh-issue-100372.utfP65.rst | 2 ++
+ Modules/_ssl.c | 10 ++++++----
+ 3 files changed, 10 insertions(+), 4 deletions(-)
+ create mode 100644 Misc/NEWS.d/next/Library/2022-12-20-10-55-14.gh-issue-100372.utfP65.rst
+
+diff --git a/Lib/test/test_ssl.py b/Lib/test/test_ssl.py
+index ce40b09bb6..32854853d3 100644
+--- a/Lib/test/test_ssl.py
++++ b/Lib/test/test_ssl.py
+@@ -1204,6 +1204,8 @@ class ContextTests(unittest.TestCase):
+ "not enough data: cadata does not contain a certificate"
+ ):
+ ctx.load_verify_locations(cadata=b"broken")
++ with self.assertRaises(ssl.SSLError):
++ ctx.load_verify_locations(cadata=cacert_der + b"A")
+
+ def test_load_dh_params(self):
+ ctx = ssl.SSLContext(ssl.PROTOCOL_TLSv1)
+diff --git a/Misc/NEWS.d/next/Library/2022-12-20-10-55-14.gh-issue-100372.utfP65.rst b/Misc/NEWS.d/next/Library/2022-12-20-10-55-14.gh-issue-100372.utfP65.rst
+new file mode 100644
+index 0000000000..ec37aff509
+--- /dev/null
++++ b/Misc/NEWS.d/next/Library/2022-12-20-10-55-14.gh-issue-100372.utfP65.rst
+@@ -0,0 +1,2 @@
++:meth:`ssl.SSLContext.load_verify_locations` no longer incorrectly accepts
++some cases of trailing data when parsing DER.
+diff --git a/Modules/_ssl.c b/Modules/_ssl.c
+index ab8a327d10..d31e1960ec 100644
+--- a/Modules/_ssl.c
++++ b/Modules/_ssl.c
+@@ -3658,7 +3658,7 @@ _add_ca_certs(PySSLContext *self, void *data, Py_ssize_t len,
+ {
+ BIO *biobuf = NULL;
+ X509_STORE *store;
+- int retval = -1, err, loaded = 0;
++ int retval = -1, err, loaded = 0, was_bio_eof = 0;
+
+ assert(filetype == SSL_FILETYPE_ASN1 || filetype == SSL_FILETYPE_PEM);
+
+@@ -3686,6 +3686,10 @@ _add_ca_certs(PySSLContext *self, void *data, Py_ssize_t len,
+ int r;
+
+ if (filetype == SSL_FILETYPE_ASN1) {
++ if (BIO_eof(biobuf)) {
++ was_bio_eof = 1;
++ break;
++ }
+ cert = d2i_X509_bio(biobuf, NULL);
+ } else {
+ cert = PEM_read_bio_X509(biobuf, NULL,
+@@ -3721,9 +3725,7 @@ _add_ca_certs(PySSLContext *self, void *data, Py_ssize_t len,
+ }
+ _setSSLError(msg, 0, __FILE__, __LINE__);
+ retval = -1;
+- } else if ((filetype == SSL_FILETYPE_ASN1) &&
+- (ERR_GET_LIB(err) == ERR_LIB_ASN1) &&
+- (ERR_GET_REASON(err) == ASN1_R_HEADER_TOO_LONG)) {
++ } else if ((filetype == SSL_FILETYPE_ASN1) && was_bio_eof) {
+ /* EOF ASN1 file, not an error */
+ ERR_clear_error();
+ retval = 0;
diff --git a/python3.6.spec b/python3.6.spec
index aa82c88..26a6d30 100644
--- a/python3.6.spec
+++ b/python3.6.spec
@@ -17,7 +17,7 @@ URL: https://www.python.org/
#global prerel ...
%global upstream_version %{general_version}%{?prerel}
Version: %{general_version}%{?prerel:~%{prerel}}
-Release: 57%{?dist}
+Release: 58%{?dist}
# Python is Python
# pip MIT is and bundles:
# appdirs: MIT
@@ -943,6 +943,18 @@ Patch480: 00480-cve-2026-4786.patch
# Backported from Python 3.10
Patch482: 00482-cve-2026-6100.patch
+# 00489 # 00bd500a6c87df569b281458d878bebbebdd9a0c
+# Use BIO_eof to detect EOF for SSL_FILETYPE_ASN1
+#
+# In PEM, we need to parse until error and then suppress `PEM_R_NO_START_LINE`, because PEM allows arbitrary leading and trailing data. DER, however, does not. Parsing until error and suppressing `ASN1_R_HEADER_TOO_LONG` doesn't quite work because that error also covers some cases that should be rejected.
+#
+# Instead, check `BIO_eof` early and stop the loop that way.
+#
+# This fixes https://github.com/python/cpython/issues/151504 and adds compatibility with OpenSSL 3.5.7+
+#
+# (cherry-picked from commit acfe02f3b05436658d92add6b168538b30f357f0)
+Patch489: 00489-openssl-3.5.7.patch
+
# (New patches go here ^^^)
#
# When adding new patches to "python" and "python3" in Fedora, EL, etc.,
@@ -2244,6 +2256,9 @@ CheckPython optimized
# ======================================================
%changelog
+* Thu Jul 02 2026 Miro Hrončok <mhroncok@redhat.com> - 3.6.15-58
+- Fix ssl.SSLError: [ASN1: NOT_ENOUGH_DATA] not enough data with OpenSSL 3.5.7+
+
* Fri Apr 17 2026 Charalampos Stratakis <cstratak@redhat.com> - 3.6.15-57
- Security fixes for CVE-2026-4786, CVE-2026-6100
Resolves: rhbz#2458018, rhbz#2458226
reply other threads:[~2026-07-05 20:24 UTC|newest]
Thread overview: [no followups] expand[flat|nested] mbox.gz Atom feed
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=178328309145.1.10582343655231122092.rpms-python3.6-a566adb37458@fedoraproject.org \
--to=git-commits@fedoraproject.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox