Skip to content

Commit 495bd03

Browse files
authored
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)
1 parent 40e700a commit 495bd03

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
@@ -805,10 +805,11 @@ PySSL_SetError(PySSLSocket *sslsock, int ret, const char *filename, int lineno)
805805
errno = err.c;
806806
return PyErr_SetFromErrno(PyExc_OSError);
807807
}
808-
Py_INCREF(s);
809-
s->errorhandler();
810-
Py_DECREF(s);
811-
return NULL;
808+
else {
809+
p = PY_SSL_ERROR_EOF;
810+
type = PySSLEOFErrorObject;
811+
errstr = "EOF occurred in violation of protocol";
812+
}
812813
} else { /* possible? */
813814
p = PY_SSL_ERROR_SYSCALL;
814815
type = PySSLSyscallErrorObject;

0 commit comments

Comments
 (0)