60

I have a Blazor client/server app that I have been working on for a period and it has been working fine up to now. I suddenly started getting this error

Failed to find a valid digest in the 'integrity' attribute for resource 'https://mydomain.no/_framework/Faso.Blazor.SpinKit.dll' with computed SHA-256 integrity '1UEuhA1KzEN0bQcoU0m1eL4WKcCIWHhPgoXydAJnO9w='. The resource has been blocked.

Failed to find a valid digest in the 'integrity' attribute for resource

I have tried to clean and rebuild. I have tried to add Cors, set folder permission, and many other suggested solutions, but to no avail. I am using web deploy in VS 2022 and Win Server 2016, .net core 5.0.

TylerH
  • 20,799
  • 66
  • 75
  • 101
Bjørn Hellesylt
  • 805
  • 2
  • 7
  • 10
  • 4
    I know its not a proper solution but for me deleting all .br and .gz files in the wwwroot\\_framework directory on the server solved the problem. So it must be a problem with th ecompressed versions of the files and not the normal dll files (at least in my case) – Paul Nov 12 '21 at 10:55
  • Paul brings up an important point - ensure all files on the server gets updated, and is also not stuck in a cache somewhere. – Michel Jansson Nov 12 '21 at 11:42
  • In all honesty - in the development environment, please disable integrity checks. Speeds up the whole process a lot – eagle275 Feb 17 '22 at 09:03

10 Answers10

109

This is an annoying issue indeed and I'm getting that error every now and then. It seems to happen after updating some packages, and the build processes fails to pick up the new SHA for the package.

You can verify that this is the issue by finding the file containing the SHAs and compare the SHA for the dll in question with the SHA from the error message. This file is called blazor.boot.json and is generated deep inside the obj-folder of your project folder. (mine was here: obj\Release\net6.0\win-x86\PubTmp\Out\wwwroot\_framework)

If was the issue, please try this:

  1. Close VS.
  2. Delete the obj and bin folders from all your projects. (the web project might be enough, but hey - can't hurt)
  3. Start VS
  4. Rebuild solution.
  5. Try Publish again.
Michel Jansson
  • 1,803
  • 1
  • 13
  • 14
  • 3
    Thanks a lot. I tried all this but the SHAs do not match after I deployed again. I compared the SHA on the server with the error message and they also do not match. – Bjørn Hellesylt Nov 12 '21 at 03:10
  • 1
    @BjørnHellesylt, so after deleting all build output per the steps, and rebuilding, it has generated an the same old SHA again on your local machine? – Michel Jansson Nov 12 '21 at 11:33
  • 1
    @MichelJansson, no it generated different SHAs, but they did not match the ones in the error that was also new. – Bjørn Hellesylt Nov 13 '21 at 06:13
  • 1
    @BjørnHellesylt maybe try following [this troubleshooting guide from MS](https://learn.microsoft.com/en-us/aspnet/core/blazor/host-and-deploy/webassembly?view=aspnetcore-5.0#resolve-integrity-check-failures-1), especially the part about the ps script to figure out what the correct SHA is. Then from this, if it turns out your blazor.boot file was correct all along - ensure that all files actually have been updated on the webserver. – Michel Jansson Nov 13 '21 at 21:28
  • 2
    These steps didn't work for me. I blew away local files, temp files, server files, but .net 6/vs2022 latest brand new blazor wasm app fails due to different shas. – inliner49er Nov 27 '21 at 18:10
  • 1
    Thanks, this helped, but I had to delete the whole solution, not only the bin and obj folders. – Davorin Puhar Jan 24 '22 at 12:33
  • I tried a Clean and Rebuild of the solution first after reading this and that was all it took to fix it for me. – dimension314 Sep 08 '22 at 15:42
  • If your publish folder is separate from you bin folder, delete the files there too. – Joao Ricardo Nov 29 '22 at 23:02
  • Worked for me, thanks! – MikeT Aug 29 '23 at 11:11
5

What worked for me was using my FTP client and changing the transfer type from "auto" to "binary" (Transfer > Transfer Type > Binary). I don't see an option for doing this in Visual Studio 2022, so I guess I'll use my manual FTP client solution for now.

TylerH
  • 20,799
  • 66
  • 75
  • 101
inliner49er
  • 1,300
  • 1
  • 11
  • 19
  • How is this even _relevant_ to the problem OP had? This sounds like an XY solution. There's also gotta be some critical information missing here, like transferring files from one type of OS to another (e.g. Windows to Linux or vice versa) where this could even become a problem. – TylerH Aug 24 '23 at 13:13
3

Check this note from: https://learn.microsoft.com/en-us/aspnet/core/blazor/host-and-deploy/webassembly?view=aspnetcore-6.0

Resolve integrity check failures: When Blazor WebAssembly downloads an app's startup files, it instructs the browser to perform integrity checks on the responses. Blazor sends SHA-256 hash values for DLL (.dll), WebAssembly (.wasm), and other files in the blazor.boot.json file, which isn't cached on clients. The file hashes of cached files are compared to the hashes in the blazor.boot.json file. For cached files with a matching hash, Blazor uses the cached files. Otherwise, files are requested from the server. After a file is downloaded, its hash is checked again for integrity validation. An error is generated by the browser if any downloaded file's integrity check fails.

If after deleted obj and bin folders the error continues, be sure that you are deleting the cache on your client browser of the site (Ctrl + F5)

Jav_1
  • 462
  • 5
  • 12
  • This seems like commentary on the answer by Michel Janson a year prior rather than its own solution. You suggest the same thing, just also "clear browser cache _if needed_". In fact someone _did_ comment this exact solution under Michel's answer a month prior to your answer: https://i.stack.imgur.com/jb6Z1.png – TylerH Aug 24 '23 at 13:15
2

I put my Web API service and Blazor Wasm projects on the same server with different subdomains. Both of them are using .NET 6. Although the Web API works well, the Blazor project gave that error.

Then I tried to move Blazor project to another server that another Blazor Wasm is already working and Bingo!

While it gave problem in Windows Server 2022 with IIS 10.0.20348.1 and .NET Core Hosting Bundle 6.0.7, it worked with the same files in Windows Server 2019 with IIS 10.0.17763.1 and .NET Core Hosting Bundle 6.0.6.

TylerH
  • 20,799
  • 66
  • 75
  • 101
Omer Faruk KAYA
  • 342
  • 2
  • 10
  • This just sounds like you configured your 2022 server incorrectly. Doesn't sound like a helpful solution since assembly files or their integrity should not change from server to server. – TylerH Aug 24 '23 at 13:21
  • What kind of server misconfiguration can cause this error? I have installed Windows Server and Plesk as usual and Plesk is configuring IIS and .Net Core. – Omer Faruk KAYA Aug 25 '23 at 01:47
  • And as I remember, there was an error that I couldn't resolve only for PUT requests in backend side. I tried many things in the server but problem was not solved. After moving the same files to another server, the error was gone. I know there was something wrong but the question is what is the reason? – Omer Faruk KAYA Aug 25 '23 at 01:53
  • That's a good question--and one that you definitely should not leave unanswered in a solution that claims that is the problem. These technologies work just fine on IIS 10 on Windows Server 2022, so the issue must be on the user side. – TylerH Aug 25 '23 at 13:12
2

For me (I've updated the SDK from .NET 6 to 7), the solution was the following order of action:

  • Clear all bin and obj folders
  • Clear all nuget cache instruction
  • Run the app and clear the browser cache (Ctrl+F5)
lebar
  • 31
  • 5
  • Did you try without clearing your NuGet cache first? This seems just like repeating the top answer and adding one extra step. – TylerH Aug 24 '23 at 13:19
2

In most cases, the warning 'Failed to find a valid digest in the 'integrity' attribute for resource......' doesn't indicate a problem with integrity checking. Instead, the warning usually means that some other problem exists.

In my case, when I deployed my "Blazor Custom Elements" on an APACHE server (to integrate it into a PHP website), it worked fine on FireFox but I had this problem on Edge and Chrome! I still haven't found out why.

Adding this property to the .csproj. file disables the integrity check and it works :

<BlazorCacheBootResources>false</BlazorCacheBootResources>

Microsoft has a fairly extensive and complex documentation here : https://learn.microsoft.com/en-us/aspnet/core/blazor/host-and-deploy/webassembly?view=aspnetcore-7.0&WT.mc_id=DT-MVP-5000641#disable-integrity-checking-for-non-pwa-apps

Toss Net
  • 420
  • 5
  • 13
  • So, your answer is that **1.** a claim that the error message secretly doesn't mean what it says it means, **2.** you don't know why you got the error in the first place (see why I find #1 hard to believe?), and **3.** to just circumvent integrity checking altogether instead of fixing the root cause (which--just to remind readers--you said you didn't know)? I'm not sure how this is helpful. Perhaps just a comment under the question suggesting to disable integrity checking would have been better... like someone [already did](https://stackoverflow.com/q/69926878/#comment125779286_69926878)... – TylerH Aug 24 '23 at 13:24
1

For me it was wrong MIME Types. There was a web.config with changes to Mime types, but I needed to mannually change it for my Blazor Page in IIS. After this it worked Web.config in Publish folder contained a section like this:

      <remove fileExtension=".blat" />
      <remove fileExtension=".dat" />
      <remove fileExtension=".dll" />
      <remove fileExtension=".json" />
      <remove fileExtension=".wasm" />
      <remove fileExtension=".woff" />
      <remove fileExtension=".woff2" />
      <mimeMap fileExtension=".blat" mimeType="application/octet-stream" />
      <mimeMap fileExtension=".dll" mimeType="application/octet-stream" />
      <mimeMap fileExtension=".dat" mimeType="application/octet-stream" />
      <mimeMap fileExtension=".json" mimeType="application/json" />
      <mimeMap fileExtension=".wasm" mimeType="application/wasm" />
      <mimeMap fileExtension=".woff" mimeType="application/font-woff" />
      <mimeMap fileExtension=".woff2" mimeType="application/font-woff" />

This conflicted with the Mime Settings in IIS After I changed the Mime Settings in IIS to the values from the web.config, it worked.

1

I deploy my Blazor app manually on Github Pages and Git changed the EoL characters in my .js files which broke the integrity checks.

Use this command to disable the autocrlf feature for the deployment repo:

git config core.autocrlf false

Then re-add all the files and folders from the publish/wwwroot folder.

I also made sure certain files were recognized as 'binary' in the .gitattributes file:

*.dll binary
*.gz binary
*.dat binary
*.blat binary
*.wasm binary
*.ico binary
*.eot binary
*.otf binary
*.ttf binary
*.woff binary

And for anyone else deploying on Github Pages, add a .nojekyll file to allow access to folders starting with _ (like _framework)

Peter L
  • 2,921
  • 1
  • 29
  • 31
0

In my case, deleting .gz and .br files was enough to solve the problem. May be not the best solution but a working one.

-2

For me, it happens if I run the same blazor app in the same browser user but with different domains. ex: 'mywebsite.z13.web.core.windows.net' and 'mywebsite.com'

Delete the cache, and run only 1 domain per browser user.

SamBerk
  • 311
  • 2
  • 10
  • 1
    This appears to repeat at least once answer and a comment under the accepted answer https://stackoverflow.com/questions/69926878/failed-to-find-a-valid-digest-in-the-integrity-attribute-for-resource-in-blazo/72982805#72982805 with the solution given in both places "clear your cache". – TylerH Aug 24 '23 at 13:40
  • But they don't explain why it's happening so you can avoid it from happening again. – SamBerk Aug 24 '23 at 17:54