code-server: [Bug]: Webview error

Is there an existing issue for this?

  • I have searched the existing issues

OS/Web Information

  • Web Browser: Brave
  • Local OS: MacOS Monterey 12.4
  • Remote OS: MacOS Monterey 12.4
  • Remote Architecture: platform=linux/amd64
  • code-server --version: /root/.local/lib/code-server-4.5.0/lib/vscode/bin/remote-cli/code-server: 12: /root/.local/lib/code-server-4.5.0/lib/vscode/node: not found

Steps to Reproduce

  1. Open code server in Brave Browser
  2. Log in
  3. Read the error message

Expected

Code server should run with all features enabled

Actual

All sorts of random problems, including broken Image display

Logs

Error loading webview: Error: Could not register service workers: SecurityError: Failed to register a ServiceWorker for scope (‘https://localhost:8080/stable-30d9c6cd9483b2cc586687151bcbcd635f373630/static/out/vs/workbench/contrib/webview/browser/pre/’) with script (‘https://localhost:8080/stable-30d9c6cd9483b2cc586687151bcbcd635f373630/static/out/vs/workbench/contrib/webview/browser/pre/service-worker.js?v=4&vscode-resource-base-authority=vscode-resource.vscode-cdn.net&remoteAuthority=localhost:8080’): An SSL certificate error occurred when fetching the script…

Screenshot/Video

No response

Does this issue happen in VS Code or GitHub Codespaces?

  • I cannot reproduce this in VS Code.
  • I cannot reproduce this in GitHub Codespaces.

Are you accessing code-server over HTTPS?

  • I am using HTTPS.

Notes

“This certificate is not trusted, expires …” and it says the time of installation

About this issue

  • Original URL
  • State: closed
  • Created 2 years ago
  • Comments: 22 (10 by maintainers)

Most upvoted comments

I found a way to get Brave to work on MacOS. I used openssl s_client -connect localhost:8080 to retrieve the auto-generated (self-signed) certificate from the running code-server instance. I created a file with the extension .crt so I could import that key into Keychain Access.app. Then I used the search function in Keychain Access and double-clicked the new certificate to select “Always trust”. This enables all features other browsers don’t seem to have an issue with - images are shown, Webviews seem to work ok, Jupyter Notebooks run.

I am cross-posting this (see https://github.com/coder/code-server/issues/4800).

So whenever someone uses the --cert option to let code server generate certificates on startup it actually breaks a lot of features? This doesn’t make much sense to me at the moment…

No. This seems to be a limitation of Brave with self-signed certificates.

No, i want code server to generate its own certificates on startup.

Then the root CA from mkcert make no difference. Because you don’t use the certificates generated by mkcert for localhost.

Agree, I think we need to generate a cert from mkcert which can be verified by your local CA. Then you use that existing cert by passing params to code-server like ./code-server --cert xxx --cert-key xxx instead of using code server generated self signed cert which can’t be verified by your local CA

@gogobd Almost certainly there is something wrong with your certificates and/or setup.

@jsjoeio This is not a code-server bug – with the exception of /root/.local/lib/code-server-4.5.0/lib/vscode/bin/remote-cli/code-server: 12: /root/.local/lib/code-server-4.5.0/lib/vscode/node: not found (👉 #5335).