paullouisageneau / libdatachannel

C/C++ WebRTC network library featuring Data Channels, Media Transport, and WebSockets
https://libdatachannel.org/
Mozilla Public License 2.0
1.82k stars 365 forks source link

Renegotiation does not set the SSL role correctly #253

Closed stazio closed 4 years ago

stazio commented 4 years ago

It seems this bug is still present. The browser is failing to accept the remote answer with the warning Failed to apply the description for m= section with mid='1': Failed to set SSL role for the transport. where mid:1 is the first mline in the description. Here is how to reproduce the issue:

  1. libdatachannel produces an offer (setup:actpass)
  2. The browser accepts and produces an answer (setup:active)
  3. libdatachannel accepts the answer
  4. The browser produces an offer (setup:actpass)
  5. libdatachannel accepts and produces an answer (setup:active)
  6. The browser rejects the offer.
paullouisageneau commented 4 years ago

OK, I'm pushing a fix.

stazio commented 4 years ago

There is still something wrong here. libdatachannel now throws a "Incompatible roles with remote description" exception. I have attached a gist here of both the offer and the answer from the perspective of the browser.

stazio commented 4 years ago

Commenting out the offending exception produces no issues as far as I can tell.

paullouisageneau commented 4 years ago

This indicates a deeper problem as it means the local setup and the remote setup are the same. How do you end up in this situation?

stazio commented 4 years ago

How do you end up in this situation?

So I went to sleep, and woke up this morning and I can no longer reproduce the issue. This certainly has to do with the fact that both the browser and libdatachannel can produce an offer, though the signaling guarantees that only one offer is ever in progress at any time.

paullouisageneau commented 4 years ago

OK, I see. The API should behave a bit like the browser one so you have to either offer always from the same side or handle conflicts yourself using the signaling state. Please re-open if you encounter such an issue again.