protect the server from multiple rehandshakes.

This commit is contained in:
Nikos Mavrogiannopoulos
2014-01-21 17:29:45 +01:00
parent d8162d3c0b
commit 5f3a6279d9
2 changed files with 22 additions and 2 deletions
+17 -1
View File
@@ -1519,7 +1519,7 @@ static int connect_handler(worker_st * ws)
parse_cstp_data(ws, ws->buffer, l, parse_cstp_data(ws, ws->buffer, l,
now); now);
if (ret < 0) { if (ret < 0) {
oclog(ws, LOG_INFO, oclog(ws, LOG_ERR,
"error parsing CSTP data"); "error parsing CSTP data");
goto exit; goto exit;
} }
@@ -1537,11 +1537,19 @@ static int connect_handler(worker_st * ws)
if (ret == GNUTLS_E_REHANDSHAKE) { if (ret == GNUTLS_E_REHANDSHAKE) {
/* rekey? */ /* rekey? */
if (ws->last_tls_rehandshake > 0 &&
now-ws->last_tls_rehandshake < ws->config->cookie_validity/3) {
oclog(ws, LOG_ERR, "client requested TLS rehandshake too soon");
goto exit;
}
oclog(ws, LOG_INFO, "client requested rehandshake on TLS channel"); oclog(ws, LOG_INFO, "client requested rehandshake on TLS channel");
do { do {
ret = gnutls_handshake(ws->session); ret = gnutls_handshake(ws->session);
} while (ret < 0 && gnutls_error_is_fatal(ret) == 0); } while (ret < 0 && gnutls_error_is_fatal(ret) == 0);
GNUTLS_FATAL_ERR(ret); GNUTLS_FATAL_ERR(ret);
ws->last_tls_rehandshake = now;
} }
} }
@@ -1584,11 +1592,19 @@ static int connect_handler(worker_st * ws)
if (ret == GNUTLS_E_REHANDSHAKE) { if (ret == GNUTLS_E_REHANDSHAKE) {
/* rekey? */ /* rekey? */
if (ws->last_dtls_rehandshake > 0 &&
now-ws->last_dtls_rehandshake < ws->config->cookie_validity/3) {
oclog(ws, LOG_ERR, "client requested DTLS rehandshake too soon");
goto exit;
}
oclog(ws, LOG_INFO, "client requested rehandshake on DTLS channel"); oclog(ws, LOG_INFO, "client requested rehandshake on DTLS channel");
do { do {
ret = gnutls_handshake(ws->dtls_session); ret = gnutls_handshake(ws->dtls_session);
} while (ret < 0 && gnutls_error_is_fatal(ret) == 0); } while (ret < 0 && gnutls_error_is_fatal(ret) == 0);
GNUTLS_FATAL_ERR(ret); GNUTLS_FATAL_ERR(ret);
ws->last_dtls_rehandshake = now;
} }
udp_recv_time = now; udp_recv_time = now;
+5 -1
View File
@@ -134,7 +134,11 @@ typedef struct worker_st {
/* set after authentication */ /* set after authentication */
int udp_fd; int udp_fd;
udp_port_state_t udp_state; udp_port_state_t udp_state;
/* protection from multiple rehandshakes */
time_t last_tls_rehandshake;
time_t last_dtls_rehandshake;
/* for mtu trials */ /* for mtu trials */
unsigned last_good_mtu; unsigned last_good_mtu;
unsigned last_bad_mtu; unsigned last_bad_mtu;