]> 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:16 +0000 (10:52 -0600)
commit3865b3fd6a2e8c98158aee0713d81913bf84ca06
tree9c8a2a87df5b98a5f01c5fb82e8758b931d0de75
parent519f21ecb2bc3b4d7ff739c41dd9a6c9ad30604a
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