Failed to find a valid digest in the 'integrity' attribute for resource in Blazor app
Asked Answered
J

14

74

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.

Jailer answered 11/11, 2021 at 10:39 Comment(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)Deoxyribose
Paul brings up an important point - ensure all files on the server gets updated, and is also not stuck in a cache somewhere.Eartha
In all honesty - in the development environment, please disable integrity checks. Speeds up the whole process a lotMicrocyte
Deleting the .gr and .gz files solved it for me this time. This problem happens from time to time after deploying.Abstracted
E
134

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.
Eartha answered 11/11, 2021 at 21:27 Comment(9)
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.Abstracted
@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?Eartha
@MichelJansson, no it generated different SHAs, but they did not match the ones in the error that was also new.Abstracted
@BjørnHellesylt maybe try following this troubleshooting guide from MS, 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.Eartha
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.Gunk
Thanks, this helped, but I had to delete the whole solution, not only the bin and obj folders.Schnapps
I tried a Clean and Rebuild of the solution first after reading this and that was all it took to fix it for me.Shive
If your publish folder is separate from you bin folder, delete the files there too.Rahman
Mads Kristensen has an extension, Tweaks, that will delete bin/obj folders on Build > CleanBrookner
G
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.

Gunk answered 5/12, 2021 at 18:21 Comment(4)
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.Nieberg
@TylerH, what do you mean by implying my answer is not "relevant"? He clearly states "I am using web deploy in VS 2022", so the OP's issue was re publishing/deployment. My workaround was also for publishing/deployment (via manual ftp). The accepted answer of over 125 votes was also for "5. Try Publish again." So please explain why my workaround is irrelevant, so that you can educate the rest of us.Gunk
Because you're not using VS at all; OP is asking why VS is causing an issue and how to solve it. And what does transfer type have to do with anything? You have provided a very poor workaround (missing substantial details, as I said; you can't "just deploy your code via FTP-where are the compile steps? How do you structure files and folders during upload, etc.?"), but not answered the question or directly/sufficiently addressed the problem.Nieberg
I'm using VS to get the error during publish, and the only way i found around it was to USE VS to publish to a folder and then use an external ftp client (filezilla) to upload those VS-PUBLISHED files - and i HAD TO switch the upload mode to binary (vs auto) before it worked, and that is what "tranfer type has to do with it at all". So to say "you're not using VS at all" is wrong. i would prefer to totally use VS if it weren't for this bug. This is an old post, and i now have a batch-driven publish deployment method that's my "permanent" workaround. i don't know if the vs team ever fixed this.Gunk
F
5

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 deleting the obj and bin folders the error continues, be sure that you are deleting the cache on your client browser of the site (Ctrl + F5)

Fatsoluble answered 14/7, 2022 at 15:11 Comment(1)
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: i.sstatic.net/jb6Z1.pngNieberg
K
5

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

Katmandu answered 24/2, 2023 at 8:30 Comment(2)
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...Nieberg
"In most cases, the warning doesn't indicate a problem with integrity checking. Instead, the warning usually means that some other problem exists." is coming from the useful referenced documentation.Communard
L
4

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)
Luellaluelle answered 4/2, 2023 at 19:58 Comment(1)
Did you try without clearing your NuGet cache first? This seems just like repeating the top answer and adding one extra step.Nieberg
O
3

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.

Orthographize answered 1/8, 2022 at 21:48 Comment(4)
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.Nieberg
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.Orthographize
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?Orthographize
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.Nieberg
S
3

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.

Solorio answered 16/11, 2022 at 11:33 Comment(0)
G
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)

Gus answered 9/5, 2023 at 5:5 Comment(0)
A
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.

Aeneus answered 14/4, 2023 at 22:57 Comment(0)
W
0

I struggled with a similiar problem while deploying my Blazor WASM client on the production server. Clearing cache / bin and obj folders didn't work, I kept getting the integrity and some service worker onInstall exceptions.

It turned out that the site generated some cookies connected to previously deployed version of the client. I've cleared all of the cookies and cached data from the browser and it worked, no more exceptions.

Waylon answered 13/3, 2024 at 11:11 Comment(0)
M
0

this is not only on Blazor. this is quite expected in most of SPAs. Let me clarify you, enter image description here Here it clearly says,the provided integrity value is not validating, so it means particular issued has been expired(reason could be anything).

enter image description here In my case i was trying to add font-awesome styles for that it killed 2+hrs finally,i visited the url https://cdnjs.com/libraries/font-awesome then getting linktag(dynamically it generates). that value will be resolved. enter image description here

For deployment and publishing related quick solution is disabling of false inside any propertygroup

Mapp answered 4/4, 2024 at 17:57 Comment(0)
A
0

I know this is an old question, but I was experiencing this in .NET 8 in 2024... Couldn't figure out what the problem was, when published from one machine in one instance of VS, it would give the integrity check error. When deployed from another machine, different instance of VS Studio, it wouldn't...

I realized that when I selected the "Web Deploy" option to Azure App Service rather than "Zip Deploy" I wouldn't get the error.

Don't know how or why, but this fixed the issue for me - selecting Web Deploy.

Approver answered 26/4, 2024 at 3:3 Comment(0)
W
0

For me in Blazor 8, deleting all files with the extensions:

  • *.gz
  • *.br

did the rick and now it works. If anyone could explain me why, you are more than welcome.

Whangee answered 29/5, 2024 at 18:22 Comment(0)
P
-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.

Paton answered 4/1, 2023 at 20:7 Comment(2)
This appears to repeat at least once answer and a comment under the accepted answer #69927378 with the solution given in both places "clear your cache".Nieberg
But they don't explain why it's happening so you can avoid it from happening again.Paton

© 2022 - 2025 — McMap. All rights reserved.