opyeb srihash

Diagnosing SRI and CSP failures — from console message to cause

2026-11-29 · 2 min read

A block is usually one of five things. Read the message and work down the list; most cases resolve in minutes.

From symptom to cause

The console text is the best clue you get.

SymptomCheckFix
Failed to find a valid digestHash value, line endings, deployed fileRecompute from the final file
blocked by CORS policyAccess-Control-Allow-OriginAdd the ACAO header at the CDN
integrity appears to be ignoredMissing crossoriginAdd crossorigin="anonymous"
CSP blocks inline codeHash, nonce, unsafe-inlineAdd a hash or adopt a nonce
require-sri-for has no effectDeprecated directiveMove to the integrity attribute

Algorithm and Base64

Values starting with sha1- or md5- are not supported by SRI, and the browser blocks the resource.

Bad Base64 is a format error. URL-safe characters (-, _) are not standard Base64, and broken padding changes the length. sha384 is exactly 48 bytes, sha512 exactly 64.

Missing crossorigin

Without crossorigin on a cross-origin file, the fetch is no-cors and the integrity check is skipped. This case can produce no error at all, which makes it the hardest to find.

Paste the whole tag into the validator and it is reported separately; a bare attribute string cannot show it.

CSP syntax

Hashes and nonces must be quoted, 'none' must stand alone, and a repeated directive is ignored the second time.

require-sri-for was removed from Chrome and dropped from the standard. It does nothing where it still parses, so move to the integrity attribute.

Hash mismatch

When the format is fine but the hash does not match, suspect the bytes: LF vs CRLF, a BOM, a trailing newline, or post-build minification.

If you hashed pasted code, turn on the CRLF option and check again; if it still differs, hash the file the server actually returns.

Questions

The validator says pass but the browser blocks it.

The validator reads syntax and hashes; it cannot see the real response headers. Check the ACAO header and the response size in the network panel.

Does adding integrity invalidate caches?

No. SRI does not affect the cache key. Just remember that a cached response is not verified again.

Sources

Every example here can be pasted into the workbench as it is.

Open the workbench