/*
* Tell the event handler that an FD has disappeared.
*/
- DEBUG("(TLS) Client has closed connection");
+ DEBUG("(TLS) Closing connection");
radius_update_listener(listener);
/*
/*
* Normal socket close.
*/
- if (rcode == 0) goto do_close;
+ if (rcode == 0) {
+ RDEBUG("(TLS) Client has closed the TCP connection");
+ goto do_close;
+ }
sock->ssn->dirty_in.used = rcode;
}
status = tls_application_data(sock->ssn, request);
RDEBUG3("(TLS) Application data status %d", status);
+ /*
+ * Some kind of failure. Close the socket.
+ */
+ if (status == FR_TLS_FAIL) {
+ DEBUG("(TLS) Unable to recover from TLS error, closing socket from client port %u", sock->other_port);
+ tls_socket_close(listener);
+ PTHREAD_MUTEX_UNLOCK(&sock->mutex);
+ return 0;
+ }
+
if (status == FR_TLS_MORE_FRAGMENTS) {
PTHREAD_MUTEX_UNLOCK(&sock->mutex);
return 0;
rcode = SSL_read(sock->ssn->ssl, data + sock->partial,
length - sock->partial);
if (rcode <= 0) {
- switch (SSL_get_error(sock->ssn->ssl, rcode)) {
+ int err = SSL_get_error(sock->ssn->ssl, rcode);
+ switch (err) {
case SSL_ERROR_WANT_READ:
case SSL_ERROR_WANT_WRITE:
DEBUG3("(TLS) SSL_read() returned %s", ERR_reason_error_string(rcode));
SSL_shutdown(sock->ssn->ssl);
goto do_close;
default:
+ DEBUG("(TLS) Unexpected OpenSSL error %d", err);
goto do_close;
}
}