fix(media): skip SRTP encryption when remote peer has no crypto#130
Merged
Conversation
…o#129 When SecureRTP=1 (SDES), LocalSDP() unconditionally created an SRTP context causing encrypted outbound RTP toward peers expecting plaintext. - Add hasRemoteSDP flag so answerer only includes crypto when the offerer actually offered SRTP - Clear localCtxSRTP in offerer path when remote answer has no crypto - Fix TrimLeft→TrimPrefix for crypto tag parsing Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
emiago
reviewed
Feb 25, 2026
| masterKey, masterSalt := keysalt[:keyLen], keysalt[keyLen:] | ||
| // RFC 4568/8643: only include crypto when offering (no remote SDP yet) | ||
| // or when the peer actually offered SRTP | ||
| if !s.hasRemoteSDP || s.remoteCtxSRTP != nil { |
Owner
There was a problem hiding this comment.
Hi @HectorMalot . Simpler change would be just check would be like if s.RemoteAddr != nil and not have additional hasRemoteSDP flag. Generally this is safest as remoteadd is only known after getting offer.
You could move this under this anonymous func and return nil, instead shifting. This is just my request not to have breaks with future code comming, but not required really.
Owner
|
Hi @HectorMalot . Please check comments. |
Contributor
Author
|
Thanks @emiago , I've updated to checking |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Fixes #129
When SecureRTP=1 (SDES), LocalSDP() unconditionally created an SRTP context causing encrypted outbound RTP toward peers expecting plaintext.
Also added a small unrelated fix in the same code: