Skip to content

Commit 2434581

Browse files
bpo-31122: ssl.wrap_socket() now raises ssl.SSLEOFError rather than OSError when peer closes connection during TLS negotiation (pythonGH-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) (cherry picked from commit 495bd03) Co-authored-by: Dima Tisnek <dimaqq@gmail.com>
1 parent 0a5b30d commit 2434581

File tree

2 files changed

+6
-4
lines changed

2 files changed

+6
-4
lines changed
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
ssl.wrap_socket() now raises ssl.SSLEOFError rather than OSError when peer closes connection during TLS negotiation

Modules/_ssl.c

+5-4
Original file line numberDiff line numberDiff line change
@@ -807,10 +807,11 @@ PySSL_SetError(PySSLSocket *sslsock, int ret, const char *filename, int lineno)
807807
errno = err.c;
808808
return PyErr_SetFromErrno(PyExc_OSError);
809809
}
810-
Py_INCREF(s);
811-
s->errorhandler();
812-
Py_DECREF(s);
813-
return NULL;
810+
else {
811+
p = PY_SSL_ERROR_EOF;
812+
type = PySSLEOFErrorObject;
813+
errstr = "EOF occurred in violation of protocol";
814+
}
814815
} else { /* possible? */
815816
p = PY_SSL_ERROR_SYSCALL;
816817
type = PySSLSyscallErrorObject;

0 commit comments

Comments
 (0)