Skip to content

Commit

Permalink
Merge pull request #988 from paullouisageneau/fingerprint-precedence
Browse files Browse the repository at this point in the history
Fix fingerprint selection when different media-level attributes are present
  • Loading branch information
paullouisageneau authored Sep 20, 2023
2 parents c3b1ecd + 7fa3341 commit cee12b0
Showing 1 changed file with 11 additions and 6 deletions.
17 changes: 11 additions & 6 deletions src/description.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -120,12 +120,17 @@ Description::Description(const string &sdp, Type type, Role role)
mRole = Role::ActPass;

} else if (key == "fingerprint") {
if (match_prefix(value, "sha-256 ") || match_prefix(value, "SHA-256 ")) {
string fingerprint{value.substr(8)};
trim_begin(fingerprint);
setFingerprint(std::move(fingerprint));
} else {
PLOG_WARNING << "Unknown SDP fingerprint format: " << value;
// RFC 8122: The fingerprint attribute may be either a session-level or a
// media-level SDP attribute. If it is a session-level attribute, it applies to all
// TLS sessions for which no media-level fingerprint attribute is defined.
if (!mFingerprint || index == 0) { // first media overrides session-level
if (match_prefix(value, "sha-256 ") || match_prefix(value, "SHA-256 ")) {
string fingerprint{value.substr(8)};
trim_begin(fingerprint);
setFingerprint(std::move(fingerprint));
} else {
PLOG_WARNING << "Unknown SDP fingerprint format: " << value;
}
}
} else if (key == "ice-ufrag") {
// RFC 8839: The "ice-pwd" and "ice-ufrag" attributes can appear at either the
Expand Down

0 comments on commit cee12b0

Please sign in to comment.