From cbcff0f4fb06d46f5c00ee7eb38e20a13b152aaf Mon Sep 17 00:00:00 2001 From: Gabriele <41424282+gabridego@users.noreply.github.com> Date: Wed, 29 May 2024 17:48:15 +0200 Subject: [PATCH] rtsp: prioritise digest authentication This pull request solves a problem with security cameras that send both basic and digest realms, prioritising digest authentication. --- format/rtspv2/client.go | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/format/rtspv2/client.go b/format/rtspv2/client.go index 397f1e7..a543027 100644 --- a/format/rtspv2/client.go +++ b/format/rtspv2/client.go @@ -418,6 +418,12 @@ func (client *RTSPClient) request(method string, customHeaders map[string]string if splits[0] == "Content-length" { splits[0] = "Content-Length" } + if val, ok := res[splits[0]]; ok { + if splits[0] == "WWW-Authenticate" && strings.Contains(val, "Digest") && strings.Contains(splits[1], "Basic") { + // prioritise digest authentication + continue + } + } res[splits[0]] = splits[1] } }