microsoft / vscode

Visual Studio Code
https://code.visualstudio.com
MIT License
164.33k stars 29.31k forks source link

Can't compute SHA256 #146045

Closed RedstoneWizard08 closed 2 years ago

RedstoneWizard08 commented 2 years ago

Hi! I was trying to develop a new web extension when this error popped up in the web VS Code log. Can you help me fix it? Thanks!

[window] [error] Can't compute sha-256: Error: Can't compute sha-256

aeschli commented 2 years ago

This comes from here: https://github.com/microsoft/vscode/blob/main/src/vs/workbench/browser/webview.ts#L11

I suspect you are on Safari and the running on http://localhost. https://developer.mozilla.org/en-US/docs/Web/API/Crypto/subtle#browser_compatibility

@alexdima Can we use a fall back for that scenario? E.g. like here: https://github.com/microsoft/vscode/blob/main/src/vs/base/browser/hash.ts#L27

alexdima commented 2 years ago

@RedstoneWizard08 Can you please describe the specific setup you're using?

DanielBaumert commented 2 years ago

chromium

Access to the WebCrypto API is restricted to secure origins (which is to say https:// pages).

aeschli commented 2 years ago

@alexdima Ok to reopen and add a fall back?

alexdima commented 2 years ago

Ok to reopen and add a fall back?

@aeschli When running on localhost, the web worker extension host iframe does not use sha256 because it isn't served from our CDN, but directly from the server running on localhost. I would really like to understand the use-case before us implementing by hand sha256.

@RedstoneWizard08 What are the steps to reproduce?