pkg/tcp: support SHA-256 / SHA-512-256 RTSP Digest auth (RFC 7616) - #2344
Open
pkmanivannan wants to merge 1 commit into
Open
pkg/tcp: support SHA-256 / SHA-512-256 RTSP Digest auth (RFC 7616)#2344pkmanivannan wants to merge 1 commit into
pkmanivannan wants to merge 1 commit into
Conversation
Digest auth in pkg/tcp/auth.go was hardcoded to MD5. Some IP cameras - notably Hikvision-OEM firmware (e.g. Prama PT-NC143D3-WNM, firmware V5.8.5) and hardened/STQC-certified units - offer only SHA-256 Digest for RTSP with no MD5/Basic option, so go2rtc returns 401 Unauthorized. Select the hash from the challenge's algorithm= token per RFC 7616: MD5/absent stays byte-for-byte identical (existing cameras unaffected); SHA-256 and SHA-512-256 are added and echoed back as algorithm="...". Adds auth_test.go with independently-computed vectors for all three. Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
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.
Problem
go2rtc's RTSP Digest auth (
pkg/tcp/auth.go) is hardcoded to MD5. Some IPcameras — notably Hikvision-OEM firmware (e.g. Prama
PT-NC143D3-WNM, firmwareV5.8.5) and hardened / STQC-certified units — offer only SHA-256 Digest for
RTSP, with no MD5 or Basic option in the web UI:
Against these cameras go2rtc returns
401 Unauthorizedand the stream neverconnects. FFmpeg is also MD5-only, so the usual
ffmpeg:source fallback doesnot help either.
Change
Select the digest hash from the challenge's
algorithm=token per RFC 7616:MD5/ absent → MD5 — unchanged; the Authorization header is byte-for-byteidentical to before, so existing cameras are unaffected.
SHA-256→ SHA-256SHA-512-256→ SHA-512-256For non-MD5 algorithms the token is echoed back as
algorithm="…"in theAuthorization header (some firmware validates it); MD5 keeps the original format
with no
algorithm=. This is the no-qop Digest path already used bypkg/tcp/auth.go.Testing
pkg/tcp/auth_test.godrivesRead()→Write()for MD5, SHA-256 andSHA-512-256 and asserts the exact
response=against vectors computedindependently (Python
hashlib). All pass.SHA-256-only Hikvision-OEM camera and restreams it into Frigate, where stock
go2rtc and FFmpeg both fail with 401.
Scope / note
This covers the RTSP Digest path (
pkg/tcp/auth.go). The HTTP client inpkg/tcp/request.go(Do, used for ISAPI / snapshot) has the same MD5-onlylimitation and could be extended with the same
digestHashhelper — happy to dothat in a follow-up if wanted. I kept this PR to the path I could verify against
hardware.