dotnet / aspnetcore

ASP.NET Core is a cross-platform .NET framework for building modern cloud-based web applications on Windows, Mac, or Linux.
https://asp.net
MIT License
35.38k stars 10k forks source link

Blazor webAssembly 3.2.0 HTTPS Integrity #22929

Closed douglassimaodev closed 4 years ago

douglassimaodev commented 4 years ago

Hi,

I just created a BlazorWebAssembly 3.2 with Authentication (not asp.net hosted), here are the urls https://dev.app.uproperty.ie/ https://test.app.uproperty.ie/

and I am getting the error:

Failed to find a valid digest in the 'integrity' attribute for resource 'https://test.app.uproperty.ie/appsettings.json' with computed SHA-256 integrity '8JQgHnNVK9O1bdFW8I6JPBMvqmhebnd5e9cSgaiCwlQ='. The resource has been blocked. Unknown error occurred while trying to verify integrity. service-worker.js:1 Uncaught (in promise) TypeError: Failed to fetch Failed to find a valid digest in the 'integrity' attribute for resource 'https://test.app.uproperty.ie/appsettings.json' with computed SHA-256 integrity '8JQgHnNVK9O1bdFW8I6JPBMvqmhebnd5e9cSgaiCwlQ='. The resource has been blocked. Unknown error occurred while trying to verify integrity. service-worker.js:1 Uncaught (in promise) TypeError: Failed to fetch

any idea? it is not under any corp network of anything similar, it is just a default blazor web assembly hosted in IIS

appsettings.json inside wwwroot is Build Action = Content, Copy To output Direction= Do not Copy

(Dont worry about the information, that is just a fake website just to practice blazor)

douglassimaodev commented 4 years ago

Ok, Never mind, I get this problem when I use azure DevOps to build (pipeline) then in the release as I need to change settings from appsettings.json using IIS web app deploy in File Transforms & Variable Substitution Options then JSON variable substitution for dev/test/uat etc then I get this error, if I change the appsettings.json AFTER build/publish then I don't get it

example: VS 2019, Blazor web assembly project with Auth, Build and publish gets the files
\Release\Publish : wwwroot, web.config then put in IIS all fine

do the same process but before put in IIS to to wwwroot and edit appsettings.json then I get the error: Failed to find a valid digest in the 'integrity' attribute for resource 'https://test.app.uproperty.ie/appsettings.json' with computed SHA-256 integrity '8JQgHnNVK9O1bdFW8I6JPBMvqmhebnd5e9cSgaiCwlQ='. The resource has been blocked. etc

So Based on that, what should I do to change my appseetings.json for my environments dev/test/uat/prod?

javiercn commented 4 years ago

@douglassimaodev thanks for contacting us.

You'll likely have to have one step to recompute the hash after the change and update blazor.boot.json with it, and if you are using a PWA you will have to update the serviceworker-assets-manifest.js file too to include the updated hashes.

douglassimaodev commented 4 years ago

Thanks, I got is solved by creating 2 pipelines in azure devops, one for dev environment changing the appsettings.json variables before building and publishing, then same for test environment, and then in the release just using these 2 pipepiles the dev for dev and test for test environment release

not sure if that would be the best option but worked for me

javiercn commented 4 years ago

@douglassimaodev that's even better than my solution :)