Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Failed to find a valid digest in the 'integrity' attribute for resource Blazor Wasm #38668

Closed
brentminder opened this issue Nov 27, 2021 · 28 comments
Assignees
Labels
area-blazor Includes: Blazor, Razor Components External This is an issue in a component not contained in this repository. It is open for tracking purposes. feature-blazor-wasm This issue is related to and / or impacts Blazor WebAssembly feature-integrity-check

Comments

@brentminder
Copy link

brentminder commented Nov 27, 2021

Can anyone publish a new blazor wasm app and publish it to a domain successfully? I'm publishing within VS 2022 via FTP directly to my domain (not using CLI).

Fails:
.Net 6 blazor wasm app (vs2022) throws errors:
https://bugmonitor.com/blazor/
http://bugmonitor.com/blazor/

I'm getting:
Uncaught TypeError: Cannot read properties of undefined (reading 'register') at index.html:26
index.html:1 Failed to find a valid digest in the 'integrity' attribute for resource 'http://bugmonitor.com/blazor/wwwroot/_framework/dotnet.6.0.0.7vke5xwy70.js' with computed SHA-256 integrity '6+0cHoWrocTZHsJlI4Vt1HRaRoOkZ5m6QDd36EAAHxc='. The resource has been blocked.

Line 26 is the service-worker.js file which gets read, then blocked using https, but loads via http (looking at network files in F12/dev browser tools).

For reference, here's the page:

<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="utf-8" />
    <meta name="viewport" content="width=device-width, initial-scale=1.0, maximum-scale=1.0, user-scalable=no" />
    <title>BlazorApp3</title>
    <base href="./" />
    <link href="css/bootstrap/bootstrap.min.css" rel="stylesheet" />
    <link href="css/app.css" rel="stylesheet" />
    <link href="BlazorApp3.styles.css" rel="stylesheet" />
    <link href="manifest.json" rel="manifest" />
    <link rel="apple-touch-icon" sizes="512x512" href="icon-512.png" />
    <link rel="apple-touch-icon" sizes="192x192" href="icon-192.png" />
</head>

<body>
    <div id="app">Loading...</div>

    <div id="blazor-error-ui">
        An unhandled error has occurred.
        <a href="" class="reload">Reload</a>
        <a class="dismiss">🗙</a>
    </div>
    <script src="_framework/blazor.webassembly.js"></script>
    <script>navigator.serviceWorker.register('service-worker.js');</script>
</body>

</html>

Works:
.Net 5 blazor wasm app (vs2019) on same domain works with https or http:
https://bugmonitor.com/mysleep
http://bugmonitor.com/mysleep

@pranavkm pranavkm added the area-blazor Includes: Blazor, Razor Components label Nov 27, 2021
@pranavkm
Copy link
Contributor

@pranavkm pranavkm added the Needs: Author Feedback The author of this issue needs to respond in order for us to continue investigating this issue. label Nov 28, 2021
@ghost
Copy link

ghost commented Nov 28, 2021

Hi @brentminder. We have added the "Needs: Author Feedback" label to this issue, which indicates that we have an open question for you before we can take further action. This issue will be closed automatically in 7 days if we do not hear back from you by then - please feel free to re-open it if you come back to this issue after that time.

@brentminder
Copy link
Author

Hi Pranav,

Thanks for your prompt reply.

Regarding the article you sent, I've gone thru it as best I can. The HTTP request has only 200 responses but still has the offending error. I now have a bat file that deletes the bin/obj folders and does a publish. Then I ftp the files in the wwwroot folder into the \blazor folder on the website (which I don't control).

Here's the HTTP call:
integrity issue HTTP screenshot

And its wasm Response Content:
dotnetwasm screenshot

I'm using Hostinger.com to host this website which is successfully rendering my .net 5 blazor wasm that I referenced before, so I wouldn't think it's a problem on the hosting site itself (unless they do something different for .net 6.

As far as HTTPS goes, there are many more errors including the one plaguing both request types, so we can just focus on getting HTTP to work first.

Here's the HTTPS call:
integrity issue screenshot

@ghost ghost added Needs: Attention 👋 This issue needs the attention of a contributor, typically because the OP has provided an update. and removed Needs: Author Feedback The author of this issue needs to respond in order for us to continue investigating this issue. labels Nov 29, 2021
@mkArtakMSFT mkArtakMSFT added feature-integrity-check feature-blazor-wasm This issue is related to and / or impacts Blazor WebAssembly and removed Needs: Attention 👋 This issue needs the attention of a contributor, typically because the OP has provided an update. labels Nov 29, 2021
@brentminder
Copy link
Author

I finally solved it!

I had tried all of the things mentioned here and elsewhere, and none of it worked. What did work was using my ftp client (filezilla) and changing the transfer type from "auto" to "binary" (Transfer > Transfer Type > Binary). I don't see an option for doing this in VS2022, so I guess I'll use my manual ftp client solution for now.

@mkArtakMSFT mkArtakMSFT added this to the .NET 7 Planning milestone Dec 7, 2021
@ghost
Copy link

ghost commented Dec 7, 2021

Thanks for contacting us.

We're moving this issue to the .NET 7 Planning milestone for future evaluation / consideration. We would like to keep this around to collect more feedback, which can help us with prioritizing this work. We will re-evaluate this issue, during our next planning meeting(s).
If we later determine, that the issue has no community involvement, or it's very rare and low-impact issue, we will close it - so that the team can focus on more important and high impact issues.
To learn more about what to expect next and how this issue will be handled you can read more about our triage process here.

@mkArtakMSFT
Copy link
Member

I finally solved it!

I had tried all of the things mentioned here and elsewhere, and none of it worked. What did work was using my ftp client (filezilla) and changing the transfer type from "auto" to "binary" (Transfer > Transfer Type > Binary). I don't see an option for doing this in VS2022, so I guess I'll use my manual ftp client solution for now.

Thanks @brentminder . This helps a lot.
@vijayrkn looks like this is publishing related. Can you please take a look? Thanks!

@mkArtakMSFT mkArtakMSFT added the External This is an issue in a component not contained in this repository. It is open for tracking purposes. label Dec 7, 2021
@alex-oswald
Copy link

I'm having this exact same issue.

My difference, deployment is performed using the IIS web app deploy task in Azure Pipelines. It could be this task is causing issues if this is publishing related.

@TanayParikh
Copy link
Contributor

TanayParikh commented Dec 7, 2021

I'm having this exact same issue.

My difference, deployment is performed using the IIS web app deploy task in Azure Pipelines. It could be this task is causing issues if this is publishing related.

Are you able to attempt a binary deployment like @brentminder to confirm if this is the same issue? I'm basing this off of the following in the docs:

If some aspect of the deployment process modified the files. For example if you use a Git-based deployment mechanism, bear in mind that Git transparently converts Windows-style line endings to Unix-style line endings if you commit files on Windows and check them out on Linux. Changing file line endings change the SHA-256 hashes. To avoid this problem, consider using .gitattributes to treat build artifacts as binary files.

https://docs.microsoft.com/en-us/aspnet/core/blazor/host-and-deploy/webassembly?view=aspnetcore-6.0#diagnosing-integrity-problems

@alex-oswald
Copy link

alex-oswald commented Dec 8, 2021

@TanayParikh I can't find a way to do a binary deployment using the IIS web app deploy task. If there is a way, does someone mind pointing me in the right direction?

Publishing to a folder from Visual Studio on my workstation works fine. Is there a potential workaround to this for using the IIS web app deploy task?

@TanayParikh
Copy link
Contributor

TanayParikh commented Dec 8, 2021

Publishing to a folder from Visual Studio on my workstation works fine. Is there a potential workaround to this for using the IIS web app deploy task?

So publishing to prod from VS results in a working app, but publishing to prod from IIS Web App Deploy results in integrity check failures?

To confirm, have you reviewed https://docs.microsoft.com/en-us/aspnet/core/blazor/host-and-deploy/webassembly?view=aspnetcore-6.0#resolve-integrity-check-failures?

@alex-oswald
Copy link

alex-oswald commented Dec 9, 2021

So publishing to prod from VS results in a working app, but publishing to prod from IIS Web App Deploy results in integrity check failures?

Correct. Yes, I've viewed the page, but have not ran the script yet. I plan to do that tomorrow.

@alex-oswald
Copy link

alex-oswald commented Dec 9, 2021

image

Running the script produced the output below

ApplicationInformation

This didn't make sense to me so I debugged it. I'm not very familiar with powershell scripting but you can see that line 34 assigned PublishedAppErrors which is a string[] to $res which is an ApplicationInformation object.

I updated line 34 to $result.PublishedAppErrors = $res.Errors;.

This looks like a legit bug: https://github.com/dotnet/AspNetCore.Docs/blob/9e522de12559795483a98730f21d5904e2ffcadd/aspnetcore/blazor/host-and-deploy/webassembly/_samples/integrity.ps1#L34

Here is some of the output after updating that line.

Could not find entry for 'wwwroot/_framework/System.Text.RegularExpressions.dll in service-worker-assets.js.
Integrity mismatch for 'wwwroot/_framework/System.Text.RegularExpressions.dll (4nJCc5h7Gur8tAlUiKQqmm3gkF1dKtEWra1503T6yIo=)' and service-worker-assets.js entry ' ()'.
Could not find entry for 'wwwroot/_framework/System.Threading.dll in service-worker-assets.js.
Integrity mismatch for 'wwwroot/_framework/System.Threading.dll (mZsNOpHByGyjDLquzDAuH/3C+6k5v/PlYsd2eRAOV/k=)' and service-worker-assets.js entry ' ()'.
Could not find entry for 'wwwroot/_framework/System.Threading.Tasks.dll in service-worker-assets.js.
Integrity mismatch for 'wwwroot/_framework/System.Threading.Tasks.dll (m35lG8Qiws+5AW0HNPdScmNm4w/k6tga+pPj0CTuwsY=)' and service-worker-assets.js entry ' ()'.
Could not find entry for 'wwwroot/_framework/System.Threading.ThreadPool.dll in service-worker-assets.js.
Integrity mismatch for 'wwwroot/_framework/System.Threading.ThreadPool.dll (5L1N/JfFzo5H/1rFdRDrafPCQoWPP+3DUEgbTwXb2Bw=)' and service-worker-assets.js entry ' ()'.
Could not find entry for 'wwwroot/_framework/System.Web.HttpUtility.dll in service-worker-assets.js.
Integrity mismatch for 'wwwroot/_framework/System.Web.HttpUtility.dll (unBDUZsNPlH2DDZQ8vLXRU1pBr8NeO3J2OvYZWQG6pU=)' and service-worker-assets.js entry ' ()'.
Could not find entry for 'wwwroot/_framework/System.Xml.ReaderWriter.dll in service-worker-assets.js.
Integrity mismatch for 'wwwroot/_framework/System.Xml.ReaderWriter.dll (FLtfZkwL32vJMxOn1kQEP2ZZfaCLU0nqPxmWuw8PcYU=)' and service-worker-assets.js entry ' ()'.
Could not find entry for 'wwwroot/_framework/System.Xml.XDocument.dll in service-worker-assets.js.
Integrity mismatch for 'wwwroot/_framework/System.Xml.XDocument.dll (Dh10s3SyFxfuarzkHPkYN9gD/sass3fl3sVEhww8A0I=)' and service-worker-assets.js entry ' ()'.
Could not find entry for 'wwwroot/_framework/webcompiler.json in service-worker-assets.js.
Integrity mismatch for 'wwwroot/_framework/webcompiler.json (mWlfwifxHg1fAGCBImWq4bfXoZijNE/0akda5oG7i0w=)' and service-worker-assets.js entry ' ()'.

@TanayParikh
Copy link
Contributor

TanayParikh commented Dec 9, 2021

Thanks @alex-oswald. @guardrex have you had any issues with the script, is this something needing an update? Note:

Customization of the script might be required for your apps, including if running on version of PowerShell later than version 6.2.7.

@alex-oswald so the results show those files are in your IIS Deployed publish assets on the server, but not in the service-worker-assets.js. I wonder if those could be stale files from a prior deployment? Have you tried clearing out the folder before running the IIS task?

You had mentioned:

I'm having this exact same issue.

So does that mean you're getting a Failed to find a valid digest in the 'integrity' attribute for resource for one of the resources above?

@guardrex
Copy link
Contributor

guardrex commented Dec 9, 2021

The script was provided to me for publication on ...

dotnet/AspNetCore.Docs#20852

I haven't used/tested it. I don't recall any error reports on it until now. @alex-oswald ... You can submit a PR against the script by editing ...

https://github.com/dotnet/AspNetCore.Docs/blob/main/aspnetcore/blazor/host-and-deploy/webassembly/_samples/integrity.ps1

... or else I'll open an issue and take care of it on Friday.

UPDATE (12/10): I've opened a doc issue at dotnet/AspNetCore.Docs#24260 and will fix the script today, Friday.

UPDATE (12/10): PR is up for review.

UPDATE (12/15): The PR was approved and merged.

@alex-oswald
Copy link

@alex-oswald so the results show those files are in your IIS Deployed publish assets on the server, but not in the service-worker-assets.js. I wonder if those could be stale files from a prior deployment? Have you tried clearing out the folder before running the IIS task?

Yes, I've tried clearing out the folder before deploying. It did not make a difference.
I'm not sure what I can do to fix this for my project, but I'm glad I was able to fix a bug in your script. :)

@alex-oswald
Copy link

alex-oswald commented Dec 14, 2021

I mitigated this issue by adding a pipeline task to delete the previously deployed files before deployment. While this is not ideal, I wasn't sure what else to do.

@EquiAvia
Copy link

EquiAvia commented Dec 16, 2021

Hi All,

I am experiencing the same problem since switching to .Net 6. I have an asp.net core 6 web app which prerenders WASM components.

I deploy the application via VS2022 web deploy to an Azure App service.

image

I get the same error since updating to the below version of VS2022

image

I have manually cleared the files on the FTP site using filezilla, I have checked that the file is returned with a status 200 from the server, and I have referenced the article you posted earlier. I am stuck, please help.

image

@brentminder
Copy link
Author

brentminder commented Dec 16, 2021 via email

@EquiAvia
Copy link

Thanks Brentminder, that is okay for a one off, but we have a large number of deployments to do and we rely on the functionality.

@vijayrkn
Copy link

vijayrkn commented Apr 4, 2022

Can someone please confirm if the issue is specific to FTP & IIS Deploy scenarios from VS?

Is publishing to a folder from VS generating the correct artifacts?

If this is the case, can someone please share a binary log/ verbose msbuild log where the deployment fails to help with the investigation? Please remember to remove any sensitive content from the logs before uploading. Thanks!

@mkArtakMSFT mkArtakMSFT added the Needs: Author Feedback The author of this issue needs to respond in order for us to continue investigating this issue. label Apr 12, 2022
@ghost
Copy link

ghost commented Apr 12, 2022

Hi @brentminder. We have added the "Needs: Author Feedback" label to this issue, which indicates that we have an open question for you before we can take further action. This issue will be closed automatically in 7 days if we do not hear back from you by then - please feel free to re-open it if you come back to this issue after that time.

@brentminder
Copy link
Author

I just upgraded VS2022 (2022-04-12) with latest bits, created a new blazor wasm project, and published via the FTP server option within VS, and it works. I don't know about publishing thru the IIS path in VS.

@ghost ghost added Needs: Attention 👋 This issue needs the attention of a contributor, typically because the OP has provided an update. and removed Needs: Author Feedback The author of this issue needs to respond in order for us to continue investigating this issue. labels Apr 13, 2022
@TanayParikh TanayParikh added Needs: Author Feedback The author of this issue needs to respond in order for us to continue investigating this issue. and removed Needs: Attention 👋 This issue needs the attention of a contributor, typically because the OP has provided an update. labels Apr 13, 2022
@ghost
Copy link

ghost commented Apr 13, 2022

Hi @brentminder. We have added the "Needs: Author Feedback" label to this issue, which indicates that we have an open question for you before we can take further action. This issue will be closed automatically in 7 days if we do not hear back from you by then - please feel free to re-open it if you come back to this issue after that time.

@brentminder
Copy link
Author

@TanayParikh What further feedback do you need from me? You didn't ask me anything.

@ghost ghost added Needs: Attention 👋 This issue needs the attention of a contributor, typically because the OP has provided an update. and removed Needs: Author Feedback The author of this issue needs to respond in order for us to continue investigating this issue. labels Apr 14, 2022
@TanayParikh
Copy link
Contributor

Can someone please confirm if the issue is specific to FTP & IIS Deploy scenarios from VS?

Is publishing to a folder from VS generating the correct artifacts?

If this is the case, can someone please share a binary log/ verbose msbuild log where the deployment fails to help with the investigation? Please remember to remove any sensitive content from the logs before uploading. Thanks!

@brentminder @EquiAvia @alex-oswald would you be able to answer @vijayrkn's question above?

@TanayParikh TanayParikh removed the Needs: Attention 👋 This issue needs the attention of a contributor, typically because the OP has provided an update. label Apr 14, 2022
@TanayParikh
Copy link
Contributor

TanayParikh commented Apr 14, 2022

I just upgraded VS2022 (2022-04-12) with latest bits, created a new blazor wasm project, and published via the FTP server option within VS, and it works. I don't know about publishing thru the IIS path in VS.

Just to clarify, after you still facing this issue @brentminder?

@brentminder
Copy link
Author

As I stated, I can verify the FTP path which I originally posted about, but I cannot state anything about the IIS path since I'm not using it, and someone else posted about it. You can close the issue as far as I'm concerned. Thanks.

@vijayrkn
Copy link

Thanks @brentminder . If any one else is running into this issue with IIS please share a binlog and I will be happy to take a look.

We will go ahead and close this issue since you were the original poster and the issue is addressed for you. Thanks for the confirmation.

@ghost ghost locked as resolved and limited conversation to collaborators May 14, 2022
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
area-blazor Includes: Blazor, Razor Components External This is an issue in a component not contained in this repository. It is open for tracking purposes. feature-blazor-wasm This issue is related to and / or impacts Blazor WebAssembly feature-integrity-check
Projects
None yet
Development

No branches or pull requests

8 participants