mirror of
https://github.com/pion/webrtc.git
synced 2025-09-27 19:42:19 +08:00
Check all SDP media sections for a fingerprint
Fix RemoteDescription parsing so that it parses all sections when looking for a fingerprint, before it would fail if the first section did not contain one
This commit is contained in:
@@ -119,6 +119,7 @@ Check out the **[contributing wiki](https://github.com/pion/webrtc/wiki/Contribu
|
|||||||
* [Alex Harford](https://github.com/alexjh)
|
* [Alex Harford](https://github.com/alexjh)
|
||||||
* [Aleksandr Razumov](https://github.com/ernado)
|
* [Aleksandr Razumov](https://github.com/ernado)
|
||||||
* [mchlrhw](https://github.com/mchlrhw)
|
* [mchlrhw](https://github.com/mchlrhw)
|
||||||
|
* [AlexWoo(武杰)](https://github.com/AlexWoo) *Fix RemoteDescription parsing for certificate fingerprint*
|
||||||
|
|
||||||
### License
|
### License
|
||||||
MIT License - see [LICENSE](LICENSE) for full text
|
MIT License - see [LICENSE](LICENSE) for full text
|
||||||
|
@@ -874,7 +874,12 @@ func (pc *PeerConnection) SetRemoteDescription(desc SessionDescription) error {
|
|||||||
weOffer = false
|
weOffer = false
|
||||||
}
|
}
|
||||||
|
|
||||||
|
fingerprint, haveFingerprint := desc.parsed.Attribute("fingerprint")
|
||||||
for _, m := range pc.RemoteDescription().parsed.MediaDescriptions {
|
for _, m := range pc.RemoteDescription().parsed.MediaDescriptions {
|
||||||
|
if !haveFingerprint {
|
||||||
|
fingerprint, haveFingerprint = m.Attribute("fingerprint")
|
||||||
|
}
|
||||||
|
|
||||||
for _, a := range m.Attributes {
|
for _, a := range m.Attributes {
|
||||||
switch {
|
switch {
|
||||||
case a.IsICECandidate():
|
case a.IsICECandidate():
|
||||||
@@ -899,20 +904,16 @@ func (pc *PeerConnection) SetRemoteDescription(desc SessionDescription) error {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
fingerprint, ok := desc.parsed.Attribute("fingerprint")
|
if !haveFingerprint {
|
||||||
if !ok {
|
return fmt.Errorf("could not find fingerprint")
|
||||||
fingerprint, ok = desc.parsed.MediaDescriptions[0].Attribute("fingerprint")
|
|
||||||
if !ok {
|
|
||||||
return fmt.Errorf("could not find fingerprint")
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
var fingerprintHash string
|
|
||||||
parts := strings.Split(fingerprint, " ")
|
parts := strings.Split(fingerprint, " ")
|
||||||
if len(parts) != 2 {
|
if len(parts) != 2 {
|
||||||
return fmt.Errorf("invalid fingerprint")
|
return fmt.Errorf("invalid fingerprint")
|
||||||
}
|
}
|
||||||
fingerprint = parts[1]
|
fingerprint = parts[1]
|
||||||
fingerprintHash = parts[0]
|
fingerprintHash := parts[0]
|
||||||
|
|
||||||
// Create the SCTP transport
|
// Create the SCTP transport
|
||||||
sctp := pc.api.NewSCTPTransport(pc.dtlsTransport)
|
sctp := pc.api.NewSCTPTransport(pc.dtlsTransport)
|
||||||
|
@@ -418,3 +418,44 @@ func TestMultipleOfferAnswer(t *testing.T) {
|
|||||||
t.Errorf("Second Offer: got error: %v", err)
|
t.Errorf("Second Offer: got error: %v", err)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func TestNoFingerprintInFirstMediaIfSetRemoteDescription(t *testing.T) {
|
||||||
|
const sdpNoFingerprintInFirstMedia = `v=0
|
||||||
|
o=- 143087887 1561022767 IN IP4 192.168.84.254
|
||||||
|
s=VideoRoom 404986692241682
|
||||||
|
t=0 0
|
||||||
|
a=group:BUNDLE audio
|
||||||
|
a=msid-semantic: WMS 2867270241552712
|
||||||
|
m=video 0 UDP/TLS/RTP/SAVPF 0
|
||||||
|
c=IN IP4 192.168.84.254
|
||||||
|
a=inactive
|
||||||
|
m=audio 9 UDP/TLS/RTP/SAVPF 111
|
||||||
|
c=IN IP4 192.168.84.254
|
||||||
|
a=recvonly
|
||||||
|
a=mid:audio
|
||||||
|
a=rtcp-mux
|
||||||
|
a=ice-ufrag:AS/w
|
||||||
|
a=ice-pwd:9NOgoAOMALYu/LOpA1iqg/
|
||||||
|
a=ice-options:trickle
|
||||||
|
a=fingerprint:sha-256 D2:B9:31:8F:DF:24:D8:0E:ED:D2:EF:25:9E:AF:6F:B8:34:AE:53:9C:E6:F3:8F:F2:64:15:FA:E8:7F:53:2D:38
|
||||||
|
a=setup:active
|
||||||
|
a=rtpmap:111 opus/48000/2
|
||||||
|
a=candidate:1 1 udp 2013266431 192.168.84.254 46492 typ host
|
||||||
|
a=end-of-candidates
|
||||||
|
`
|
||||||
|
|
||||||
|
pc, err := NewPeerConnection(Configuration{})
|
||||||
|
if err != nil {
|
||||||
|
t.Error(err.Error())
|
||||||
|
}
|
||||||
|
|
||||||
|
desc := SessionDescription{
|
||||||
|
Type: SDPTypeOffer,
|
||||||
|
SDP: sdpNoFingerprintInFirstMedia,
|
||||||
|
}
|
||||||
|
|
||||||
|
err = pc.SetRemoteDescription(desc)
|
||||||
|
if err != nil {
|
||||||
|
t.Error(err.Error())
|
||||||
|
}
|
||||||
|
}
|
||||||
|
Reference in New Issue
Block a user