properly handle a DTLS handshake failure

early DTLS handshake failures would not terminate the read
loop and cause the remaining handshake bytes to be feed to
packet reader, causing an error assertion.

Rework the main read loop to terminate it when the read
event is not longer active and stop the read event on
handshake failure.

Also, make the DTLS handshake erorr message a bit more readable
by appending the WolfSSL error message to it.

Fixes issue #8.
This commit is contained in:
Andreas Schultz
2016-08-17 15:18:35 +02:00
parent 627ecd5a9e
commit de0ffd5153
4 changed files with 25 additions and 4 deletions

View File

@ -34,7 +34,7 @@ void wtp_start_dtlssetup(void)
}
if (capwap_crypt_open(&g_wtp.dtls) == CAPWAP_HANDSHAKE_ERROR) {
wtp_dfa_change_state(CAPWAP_SULKING_STATE);
wtp_abort_connecting();
} else
wtp_dfa_change_state(CAPWAP_DTLS_CONNECT_STATE);
}
@ -133,3 +133,16 @@ void wtp_teardown_connection(void)
wtp_dfa_change_state(CAPWAP_DTLS_TEARDOWN_STATE);
}
/* abort a possible DTLS connection before the handshake complete */
void wtp_abort_connecting(void)
{
/* DTLS Control */
if (g_wtp.dtls.enable)
capwap_crypt_close(&g_wtp.dtls);
/* close the control Socket */
wtp_socket_io_stop();
capwap_close_sockets(&g_wtp.net);
wtp_dfa_change_state(CAPWAP_SULKING_STATE);
}