[Python-checkins] bpo-31122: ssl.wrap_socket() now raises ssl.SSLEOFError rather than OSError when peer closes connection during TLS negotiation (GH-18772)
Dima Tisnek
webhook-mailer at python.org
Sat Aug 15 13:01:40 EDT 2020
https://github.com/python/cpython/commit/495bd035662fda29639f9d52bb6baebea31d72fa
commit: 495bd035662fda29639f9d52bb6baebea31d72fa
branch: master
author: Dima Tisnek <dimaqq at gmail.com>
committer: GitHub <noreply at github.com>
date: 2020-08-15T10:01:19-07:00
summary:
bpo-31122: ssl.wrap_socket() now raises ssl.SSLEOFError rather than OSError when peer closes connection during TLS negotiation (GH-18772)
[bpo-31122](): ssl.wrap_socket() now raises ssl.SSLEOFError rather than OSError when peer closes connection during TLS negotiation
Reproducer: http://tiny.cc/f4ztnz (tiny url because some bot keeps renaming b.p.o.-nnn as bpo links)
files:
A Misc/NEWS.d/next/Library/2020-03-11-07-44-06.bpo-31122.zIQ80l.rst
M Modules/_ssl.c
diff --git a/Misc/NEWS.d/next/Library/2020-03-11-07-44-06.bpo-31122.zIQ80l.rst b/Misc/NEWS.d/next/Library/2020-03-11-07-44-06.bpo-31122.zIQ80l.rst
new file mode 100644
index 0000000000000..2e70f7aee65c8
--- /dev/null
+++ b/Misc/NEWS.d/next/Library/2020-03-11-07-44-06.bpo-31122.zIQ80l.rst
@@ -0,0 +1 @@
+ssl.wrap_socket() now raises ssl.SSLEOFError rather than OSError when peer closes connection during TLS negotiation
\ No newline at end of file
diff --git a/Modules/_ssl.c b/Modules/_ssl.c
index 55a95ddf774e6..cb8f04a900a06 100644
--- a/Modules/_ssl.c
+++ b/Modules/_ssl.c
@@ -805,10 +805,11 @@ PySSL_SetError(PySSLSocket *sslsock, int ret, const char *filename, int lineno)
errno = err.c;
return PyErr_SetFromErrno(PyExc_OSError);
}
- Py_INCREF(s);
- s->errorhandler();
- Py_DECREF(s);
- return NULL;
+ else {
+ p = PY_SSL_ERROR_EOF;
+ type = PySSLEOFErrorObject;
+ errstr = "EOF occurred in violation of protocol";
+ }
} else { /* possible? */
p = PY_SSL_ERROR_SYSCALL;
type = PySSLSyscallErrorObject;
More information about the Python-checkins
mailing list