]> git.ipfire.org Git - thirdparty/asterisk.git/commit
res_rtp_asterisk: bad audio (static) due to incomplete dtls/srtp setup
authorKevin Harwell <kharwell@digium.com>
Thu, 13 Feb 2020 21:08:10 +0000 (15:08 -0600)
committerKevin Harwell <kharwell@digium.com>
Fri, 14 Feb 2020 16:52:05 +0000 (10:52 -0600)
commit08d8035599177f60473a150b251c20e16f97a820
tree06bdc20339ef5b342a7575754f62914c93419acb
parentf424562a41dc294f9c0175bbc8c504664ac0f75d
res_rtp_asterisk: bad audio (static) due to incomplete dtls/srtp setup

There was a race condition between client initiated DTLS setup, and handling
of server side ice completion that caused the underlying SSL object to get
cleared during DTLS initialization. If this happened Asterisk would be left
in a partial DTLS setup state. RTP packets were sent and received, but were
not being encrypted and decrypted. This resulted in no audio, or static.

Specifically, this occurred when '__rtp_recvfrom' was processing the handshake
sequence from the client to the server, and then 'ast_rtp_on_ice_complete'
gets called from another thread and clears the SSL object when calling the
'dtls_perform_setup' function. The timing had to be just right in the sense
that from the external SSL library perspective SSL initialization completed
(rtp recv), Asterisk clears/resets the SSL object (ice done), and then checks
to see if SSL is intialized (rtp recv). Since it was cleared, Asterisk thinks
it is not finished, thus not completing 'dtls_srtp_setup'.

This patch removes calls to 'dtls_perform_setup', which clears the SSL object,
in 'ast_rtp_on_ice_complete'. When ice completes, there is no reason to clear
the underlying SSL object. If an ice candidate changes a full protocol level
renegotiation occurs. Also, in the case of bundled ICE candidates are reused
when a stream is added. So no real reason to have to clear, and reset in this
instance.

Also, this patch adds a bit of extra logging to aid in diagnosis of any future
problems.

ASTERISK-28742 #close

Change-Id: I34c9e6bad5a39b087164646e2836e3e48fe6892f
res/res_rtp_asterisk.c