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 #114

Closed
albilaga opened this issue Jan 11, 2021 · 11 comments
Closed

Failed to find a valid digest in the integrity attribute #114

albilaga opened this issue Jan 11, 2021 · 11 comments
Assignees
Labels
good first issue Good for newcomers question Further information is requested

Comments

@albilaga
Copy link

albilaga commented Jan 11, 2021

Hello. First of all thank you for this beautiful theme.

I have some issues when I try to deploy the theme to github pages. When I deploy I got error message Failed to find a valid digest in the 'integrity' attribute for index.html:1 resource 'https://....' with computed SHA256 integrity '.....'. The resource has been blocked.

Right now I am following this solution https://stackoverflow.com/a/65052963/1351913 and I edited in themes/anatole/partials/head.html and remove integrity in there and it is working fine. But maybe if there is another solution for this?

@lxndrblz
Copy link
Owner

@albilaga Glad you like the theme. On the site site I can't see an integrity error.

It would be interesting to know, which script caused the error. Do you have a more complete log?

From a security point of view, it's not advisable to remove the integrity check, especially for content hosted on a CDN.

This error reminds me a lot of this issue #64, however, it seemed to be resolved by new. Somehow this issue seems very specific to GitHub Pages, I have never seen it on Netlify or anywhere else.

@lxndrblz lxndrblz self-assigned this Jan 11, 2021
@lxndrblz lxndrblz added good first issue Good for newcomers question Further information is requested labels Jan 11, 2021
@albilaga
Copy link
Author

Yes. I don't have error now because I remove the integrity. This is the part where I remove the integrity

<!-- CSS -->
    {{ $style := resources.Get "css/style.css" | resources.Minify | resources.Fingerprint }}
    <link rel="stylesheet"
          href="{{ $style.Permalink }}"
          integrity="{{ $style.Data.Integrity }}"
          crossorigin="anonymous"
          type="text/css">

I changed the integrity to integrity="" and it is working now. Not sure how to fix if I enable integrity again. And yes I am using github pages

@gofort
Copy link

gofort commented Jan 13, 2021

I have the same issue
You can check it here: https://bogdi.xyz/
BTW: just now I have updated the theme using git submodule update --remote --merge but it doesn't help

@lxndrblz
Copy link
Owner

This is an issue commonly reported on other themes too. Basically, would you need to ensure the line endings stay the same. Check out this documentation. Could you please give this a try?

Unfortunately, I can not reproduce the problem on my setup.

@gofort
Copy link

gofort commented Jan 16, 2021

Hmm, I completely remove theme, executed git config --global core.autocrlf input and added theme once again and it helped as I see.
Thank you!

@albilaga
Copy link
Author

@lxndrblz yes. Looks like that is the issue. Thank you...

@8ar10der
Copy link

I have the same issue. And I am using Windows. I try the solution provided by @gofort , executed git config --global core.autocrlf true however it not work.
My blog is https://amao.run/en

(index):1 Failed to find a valid digest in the 'integrity' attribute for resource 'https://amao.run/css/style.min.7ec96a07e10b60a6997be730fc5d4d3467a225c68515a7df6ae17ac2500f828c.css' with computed SHA-256 integrity '66pWKdY6fEah/OVFT3u1A+0m5T4mufIxbcYCWqycGtg='. The resource has been blocked.
www.googletagmanager.com/gtag/js?id=G-4GTD2DHRN1:1 Failed to load resource: net::ERR_BLOCKED_BY_CLIENT
(index):1 Failed to find a valid digest in the 'integrity' attribute for resource 'https://amao.run/js/medium-zoom.min.2d6fd0be87fa98f0c9b4dc2536b312bbca48757f584f6ea1f394abc9bcc38fbc.js' with computed SHA-256 integrity 'g8sd1f6o1C2H0eYBoH+qcwia0O+cz+Xa9gQSievMTkY='. The resource has been blocked.

@8ar10der
Copy link

8ar10der commented Apr 27, 2021

I found this related issue.
alanorth/hugo-theme-bootstrap4-blog#53

Whatever I will try to use WSL to generate the blog again to check is a Hugo-on-Windows bug.

----update----
Nope, even I use Linux (WSL) and set the config core.autocrlf to input the issue still occurs.

And, I found another interesting thing. If I rerender the blogs and push to the github. Within 10 minutes the blog displays everything fine, but after a while (maybe half an hour) my blog goes white and loses all css with the error.

@8ar10der
Copy link

8ar10der commented Apr 28, 2021

Hi guys. If you are using your own domain name. I think I may have solved this problem.

Make a long story short, turn off Cloudflare's "Always Use HTTPS" function.
Make a long story short, this issue is probably caused by the Cloudflare CDN cache. If you go to the control panel of your Cloudflare and clean your domains cache. The page will be ok.

I was suffering from this problem for a long time. By checking everyone's solutions, neither my reinstallation of the theme nor changing the git related settings solved the problem.

So, I shifted my focus. I had always suspected that there was a problem with the resource itself, so if it weren't a problem with it, it could be a problem with the browser fetching the resource. Then I thought it might be a problem with HTTPS.(This is wrong and after much practice I have proven that it is due to Cloudflare's CDN.) So I started checking my settings on Cloudflare, trying to clean the cache. And thus the problem was solved.

PS: This also solved my confusion that why every time my blog was just pushed to the Github Page everything was fine, but half an hour later there was an error.

@samuelmay
Copy link

samuelmay commented Mar 26, 2022

Hi all,

I encountered this issue, building on Windows, and deploying to GitHub pages. The site displayed fine with the Hugo server locally, but would break with this error when published and viewed on github.io.

I believe it's due to the CR/LF line endings on Windows causing the checksums to be different. Specifically for me, I narrowed it down to the fontawesome css files in "assets\fontawesome\css".

If you are encountering this issue, I would suggest editing the 3 files in this directory, and using EOL conversion in your text editor to convert them all to Unix LF endings. Then republish. As an upstream fix I might suggest that something like *.min.css text eol=lf to the .gitattributes file for this theme? I'll experiment a bit and fork/pull request when I get a chance.

The best solution I have found so far, If you are building your Hugo site on Windows, in your .github.io GitHub Pages repository, add a .gitattributes file that requests CSS files be checked out with CR/LF line endings with the line *.css text eol=crlf e.g. https://github.com/samuelmay/samuelmay.github.io/blob/main/.gitattributes

@p0n1
Copy link

p0n1 commented Aug 24, 2023

If you deployed hugo generated website with cloudflare, you may encounter CSS or JS integrity issues.

Found this solution. Works for me. https://stackoverflow.com/questions/65040931/hugo-failed-to-find-a-valid-digest-in-the-integrity-attribute-for-resource

Try to turn off Auto Minify feature for CSS or JS because cloudflare may change your CSS or JS files.

As they documented.

Note: Please note that this feature may not be fully compatible with certain newer CSS and JS language features, which could potentially affect the functionality of your site.

meisben added a commit to meisben/gic_windTurbine_website_live that referenced this issue Jan 27, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
good first issue Good for newcomers question Further information is requested
Projects
None yet
Development

No branches or pull requests

6 participants