Skip to content
  • Kevin Harwell's avatar
    res_rtp_asterisk: bad audio (static) due to incomplete dtls/srtp setup · e48f63cf
    Kevin Harwell authored
    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
    e48f63cf