mirror of
https://gitlab.com/openconnect/ocserv.git
synced 2026-10-13 18:12:03 +08:00
protect the server from multiple rehandshakes.
This commit is contained in:
+17
-1
@@ -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
@@ -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;
|
||||||
|
|||||||
Reference in New Issue
Block a user