{"id":"6f754c1ab52326fd","repo":"aio-libs/aiohttp","slug":"digest-auth-error-unsupported-hash-algorithm-al","errorCode":null,"errorMessage":"Digest auth error: Unsupported hash algorithm: {algorithm}. Supported algorithms: {supported}","messagePattern":"Digest auth error: Unsupported hash algorithm: (.+?)\\. Supported algorithms: (.+?)","errorType":"exception","errorClass":"ClientError","httpStatus":null,"severity":"error","filePath":"aiohttp/client_middleware_digest_auth.py","lineNumber":293,"sourceCode":"        path = URL(url).raw_path_qs\n\n        # Process QoP\n        qop = \"\"\n        qop_bytes = b\"\"\n        if qop_raw:\n            valid_qops = {\"auth\", \"auth-int\"}.intersection(\n                {q.strip() for q in qop_raw.split(\",\") if q.strip()}\n            )\n            if not valid_qops:\n                raise ClientError(\n                    f\"Digest auth error: Unsupported Quality of Protection (qop) value(s): {qop_raw}\"\n                )\n\n            qop = \"auth-int\" if \"auth-int\" in valid_qops else \"auth\"\n            qop_bytes = qop.encode(\"utf-8\")\n\n        if algorithm not in DigestFunctions:\n            raise ClientError(\n                f\"Digest auth error: Unsupported hash algorithm: {algorithm}. \"\n                f\"Supported algorithms: {', '.join(SUPPORTED_ALGORITHMS)}\"\n            )\n        hash_fn: Final = DigestFunctions[algorithm]\n\n        def H(x: bytes) -> bytes:\n            \"\"\"RFC 7616 Section 3: Hash function H(data) = hex(hash(data)).\"\"\"\n            return hash_fn(x).hexdigest().encode()\n\n        def KD(s: bytes, d: bytes) -> bytes:\n            \"\"\"RFC 7616 Section 3: KD(secret, data) = H(concat(secret, \":\", data)).\"\"\"\n            return H(b\":\".join((s, d)))\n\n        # Calculate A1 and A2\n        A1 = b\":\".join((self._login_bytes, realm_bytes, self._password_bytes))\n        A2 = f\"{method.upper()}:{path}\".encode()\n        if qop == \"auth-int\":\n            if isinstance(body, Payload):  # will always be empty bytes unless Payload","sourceCodeStart":275,"sourceCodeEnd":311,"githubUrl":"https://github.com/aio-libs/aiohttp/blob/c0ef574e29109210e96e652771ae4e7b88615fa4/aiohttp/client_middleware_digest_auth.py#L275-L311","documentation":"Raised as a ClientError when the 'algorithm' field of a Digest challenge names a hash aiohttp does not implement. The supported set is defined in DigestFunctions/SUPPORTED_ALGORITHMS (typically MD5, MD5-SESS, SHA-256, SHA-256-SESS). The original case is preserved for the response, but matching is case-insensitive.","triggerScenarios":"Fires at line 292-296 when `algorithm.upper()` is not a key in DigestFunctions. Triggered by challenges advertising algorithms like SHA-512, SHA3-256, or proprietary names.","commonSituations":"Server hardened to SHA-512 only; experimental auth modules; mismatch between server-side digest algorithm availability and what aiohttp supports in your installed version.","solutions":["Reconfigure the server to use SHA-256 (the recommended secure algorithm aiohttp supports).","Upgrade aiohttp to a newer version that may have added the algorithm.","If SHA-512 is mandatory, use a client library that implements it or contribute the hash function to DigestFunctions."],"exampleFix":"# before: server sends algorithm=SHA-512\n# after (Apache htdigest / nginx): configure algorithm=SHA-256","handlingStrategy":"try-catch","validationCode":null,"typeGuard":null,"tryCatchPattern":"from aiohttp import ClientError\ntry:\n    resp = await session.get(url, auth=DigestAuth(login, pwd))\nexcept ClientError as e:\n    if \"Unsupported hash algorithm\" in str(e):\n        # server uses an algorithm aiohttp can't compute; switch auth or client","preventionTips":["Standardize server digest config on SHA-256.","Log the algorithm field from the challenge for diagnostics.","Check aiohttp release notes when adding new algorithms."],"tags":["auth","digest-auth","cryptography","configuration"],"analyzedSha":"c0ef574e29109210e96e652771ae4e7b88615fa4","analyzedAt":"2026-08-04T19:51:05.467Z","schemaVersion":2}