Index: tlsIO.c ================================================================== --- tlsIO.c +++ tlsIO.c @@ -257,12 +257,16 @@ switch (err) { case SSL_ERROR_NONE: dprintBuffer(buf, bytesRead); break; case SSL_ERROR_SSL: + dprintf("SSL negotiation error, indicating that the connection has been aborted"); + Tls_Error(statePtr, TCLTLS_SSL_ERROR(statePtr->ssl, bytesRead)); *errorCodePtr = ECONNABORTED; + bytesRead = -1; + break; case SSL_ERROR_SYSCALL: backingError = ERR_get_error(); if (backingError == 0 && bytesRead == 0) { @@ -277,10 +281,20 @@ dprintf("I/O error occured (backingError = %lu)", backingError); *errorCodePtr = backingError; bytesRead = -1; } + break; + case SSL_ERROR_ZERO_RETURN: + dprintf("Got SSL_ERROR_ZERO_RETURN, this means an EOF has been reached"); + bytesRead = 0; + *errorCodePtr = 0; + break; + default: + dprintf("Unknown error (err = %i), mapping to EOF", err); + *errorCodePtr = 0; + bytesRead = 0; break; } dprintf("Input(%d) -> %d [%d]", bufSize, bytesRead, *errorCodePtr); return(bytesRead); @@ -387,10 +401,11 @@ dprintf(" write X BLOCK"); break; case SSL_ERROR_ZERO_RETURN: dprintf(" closed"); written = 0; + *errorCodePtr = 0; break; case SSL_ERROR_SYSCALL: backingError = ERR_get_error(); if (backingError == 0 && written == 0) {