SSL EOF

Clarence Gardner clarence at netlojix.com
Tue Jan 30 12:45:42 EST 2001


On Mon, 29 Jan 2001, Darren New wrote:
>Clarence Gardner wrote:
>> The issue is the SSL support in the socket module, which raises an
>> exception when the reading socket is at EOF, rather than returning an
>> empty string.
>
>Do you mean when the SSL library reads EOF on the socket, or when you read
>EOF from the SSL library? SSL requires packets that say "I'm closing the
>socket", and I can understand getting an error if the other side is (for
>example) just exitting without telling its SSL to close the socket first.
>
Here is the relevant code.  I don't know what error==6 signifies, but even
if the other side closed improperly, I don't think that's so significant as to
warrant making these sockets behave differently from non-ssl ones.

    count = SSL_read(self->ssl, PyString_AsString(buf), len);
    res = SSL_get_error(self->ssl, count);

    switch (res) {
    case 0:         /* Good return value! */
        break;
    case 6:
        PyErr_SetString(SSLErrorObject, "EOF");
        Py_DECREF(buf);
        return NULL;
        break;
    case 5:
    default:
        return PyErr_SetFromErrno(SSLErrorObject);
        break;




More information about the Python-list mailing list