mirror of
https://gitlab.torproject.org/tpo/core/tor.git
synced 2024-12-06 19:41:15 +01:00
Merge remote-tracking branch 'asn/bug4312'
This commit is contained in:
+18
-7
@@ -1146,10 +1146,6 @@ connection_or_tls_renegotiated_cb(tor_tls_t *tls, void *_conn)
|
||||
or_connection_t *conn = _conn;
|
||||
(void)tls;
|
||||
|
||||
/* Don't invoke this again. */
|
||||
tor_tls_set_renegotiate_callback(tls, NULL, NULL);
|
||||
tor_tls_block_renegotiation(tls);
|
||||
|
||||
if (connection_tls_finish_handshake(conn) < 0) {
|
||||
/* XXXX_TLS double-check that it's ok to do this from inside read. */
|
||||
/* XXXX_TLS double-check that this verifies certificates. */
|
||||
@@ -1157,6 +1153,20 @@ connection_or_tls_renegotiated_cb(tor_tls_t *tls, void *_conn)
|
||||
}
|
||||
}
|
||||
|
||||
/** Invoked on the server side using a timer from inside
|
||||
* tor_tls_got_client_hello() when the server receives excess
|
||||
* renegotiation attempts; probably indicating a DoS. */
|
||||
static void
|
||||
connection_or_close_connection_cb(evutil_socket_t fd, short what, void *_conn)
|
||||
{
|
||||
or_connection_t *conn = _conn;
|
||||
(void) what;
|
||||
(void) fd;
|
||||
|
||||
connection_stop_reading(TO_CONN(conn));
|
||||
connection_mark_for_close(TO_CONN(conn));
|
||||
}
|
||||
|
||||
/** Move forward with the tls handshake. If it finishes, hand
|
||||
* <b>conn</b> to connection_tls_finish_handshake().
|
||||
*
|
||||
@@ -1203,8 +1213,9 @@ connection_tls_continue_handshake(or_connection_t *conn)
|
||||
/* v2/v3 handshake, but not a client. */
|
||||
log_debug(LD_OR, "Done with initial SSL handshake (server-side). "
|
||||
"Expecting renegotiation or VERSIONS cell");
|
||||
tor_tls_set_renegotiate_callback(conn->tls,
|
||||
tor_tls_set_renegotiate_callbacks(conn->tls,
|
||||
connection_or_tls_renegotiated_cb,
|
||||
connection_or_close_connection_cb,
|
||||
conn);
|
||||
conn->_base.state = OR_CONN_STATE_TLS_SERVER_RENEGOTIATING;
|
||||
connection_stop_writing(TO_CONN(conn));
|
||||
@@ -1266,8 +1277,9 @@ connection_or_handle_event_cb(struct bufferevent *bufev, short event,
|
||||
} else if (tor_tls_get_num_server_handshakes(conn->tls) == 1) {
|
||||
/* v2 or v3 handshake, as a server. Only got one handshake, so
|
||||
* wait for the next one. */
|
||||
tor_tls_set_renegotiate_callback(conn->tls,
|
||||
tor_tls_set_renegotiate_callbacks(conn->tls,
|
||||
connection_or_tls_renegotiated_cb,
|
||||
connection_or_close_connection_cb,
|
||||
conn);
|
||||
conn->_base.state = OR_CONN_STATE_TLS_SERVER_RENEGOTIATING;
|
||||
/* return 0; */
|
||||
@@ -1536,7 +1548,6 @@ connection_tls_finish_handshake(or_connection_t *conn)
|
||||
connection_or_init_conn_from_address(conn, &conn->_base.addr,
|
||||
conn->_base.port, digest_rcvd, 0);
|
||||
}
|
||||
tor_tls_block_renegotiation(conn->tls);
|
||||
return connection_or_set_state_open(conn);
|
||||
} else {
|
||||
conn->_base.state = OR_CONN_STATE_OR_HANDSHAKING_V2;
|
||||
|
||||
Reference in New Issue
Block a user