You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
Extensions using web views not working with self signed certificate #5671
The preview of the Markdown document should be shown.
Actual
The preview windows remains empty.
Logs
code-server --verbose
Nothing that is related to this error/bug.
Code-Server Webview
Error loading webview: Error: Could not register service workers: SecurityError: Failed to register a ServiceWorker for scope ('https://192.168.107.129:8080/stable-784b0177c56c607789f9638da7b6bf3230d47a8c/static/out/vs/workbench/contrib/webview/browser/pre/') with script ('https://192.168.107.129:8080/stable-784b0177c56c607789f9638da7b6bf3230d47a8c/static/out/vs/workbench/contrib/webview/browser/pre/service-worker.js?v=4&vscode-resource-base-authority=vscode-resource.vscode-cdn.net&remoteAuthority=192.168.107.129:8080'): An SSL certificate error occurred when fetching the script..
Screenshot/Video
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 happens only on my local deployment with the self signed certificate.
My external deployment with a lets encrypt certificate does work as expected.
I believe this is because Chrome always rejects invalid
certificates for service workers even if you have accepted the
prompt that warns you about the certificate. I think there are
other browsers that will allow it (like Firefox, for now anyway).
So it is not something we can fix unfortunately.
If this is just temporary for testing Chrome could be launched
with --ignore-certificate-errors. Otherwise the self-signed
certificate will need to be made trusted. This could be done on
the system level or in Chrome (there should be a place to import
certificates somewhere).
In the docs we recommend mkcert. Wonder if we can deprecate code-server's built-in certificate generator for that or at least add a warning to the output.
In the docs we recommend mkcert. Wonder if we can deprecate code-server's built-in certificate generator for that or at least add a warning to the output.
Yeah that might be a good move overall. It would lead to less frustration IMO.
Hello, this is actually happening for all the extensions I use and tested: Markdown preview, git history, git graph, and another one i can't remember.
These extensions are essential in my case (course based on code server, which i find super useful) so any solution on how to fix this problem would be very helpful.
Meanwhile even a code server version someone could rollback too (for which extensions are working) could be useful for those facing this case i believe
Yeah this will affect any extension that uses web views since Code
uses iframes and service workers for web views.
I think web views have always used service workers in which case
there is no version of code-server that will work but someone will
have to test older versions to see if that is true. Maybe there
is an old version that did not use service workers.
To summarize the remaining fixes:
1. Use a certificate signed by an authority (Let's Encrypt, etc).
2. Add the certificate to the system certificate store.
3. Add the certificate to the browser certificate store.
4. Use a browser that does not have the same restrictions.
5. Roll back to an older browser version.
6. Bypass certificate errors with a flag to the browser.
So what would be the steps to do for a server once it is configured with Let's Encrypt? Just set yes to use cert in code server configuration file ? Anything else ?
There are two main options for using a Let's Encrypt certificate:
1. Use a reverse proxy like NGINX or Caddy to handle the
certificate. Here are guides for setting that up and automating
certificate renewal:
https://github.com/coder/code-server/blob/main/docs/guide.md#using-lets-encrypt-with-caddyhttps://github.com/coder/code-server/blob/main/docs/guide.md#using-lets-encrypt-with-nginx
If you are using a reverse proxy set `cert` to false in code-server
(or remove the flag).
2. To have code-server directly handle the cert set code-server's
`cert` flag to the path of the Let's Encrypt cert and `cert-key` to the
key for the certificate.
The code-server invocation should look something like this:
```
code-server --cert /path/to/cert.crt --cert-key /path/to/key.pem
```
Thank you very much...
I've defined http://192.168.107.129:8080 as secure origin in chrome://flags/#unsafely-treat-insecure-origin-as-secure and it works. :-)
Using the auto generated self signed cert (cert: true) and defining https://192.168.107.129:8080 (https Instead of http) does not work.
changed the title [-][Bug]: Markdown preview not working with self signed certificate (SecurityError)[/-][+]Extensions using web views not working with self signed certificate[/+]on May 22, 2024
Activity
jsjoeio commentedon Oct 19, 2022
@code-asher is this something we can fix or is this an issue outside code-server? I can't tell
code-asher commentedon Oct 20, 2022
code-asher commentedon Oct 20, 2022
In the docs we recommend mkcert. Wonder if we can deprecate code-server's built-in certificate generator for that or at least add a warning to the output.
jsjoeio commentedon Oct 20, 2022
Yeah that might be a good move overall. It would lead to less frustration IMO.
neurorepro commentedon Oct 22, 2022
Hello, this is actually happening for all the extensions I use and tested: Markdown preview, git history, git graph, and another one i can't remember.
These extensions are essential in my case (course based on code server, which i find super useful) so any solution on how to fix this problem would be very helpful.
Meanwhile even a code server version someone could rollback too (for which extensions are working) could be useful for those facing this case i believe
code-asher commentedon Oct 24, 2022
neurorepro commentedon Oct 24, 2022
So what would be the steps to do for a server once it is configured with Let's Encrypt? Just set yes to use cert in code server configuration file ? Anything else ?
code-asher commentedon Oct 24, 2022
jneuhauser commentedon Oct 25, 2022
Thanks for your inputs.
So to use code-server with working service workers we need a trusted certificate?
Is it possible to get service workers working with http on chrome?
code-asher commentedon Oct 27, 2022
jneuhauser commentedon Oct 28, 2022
Thank you very much...
I've defined
http://192.168.107.129:8080as secure origin inchrome://flags/#unsafely-treat-insecure-origin-as-secureand it works. :-)Using the auto generated self signed cert (
cert: true) and defininghttps://192.168.107.129:8080(https Instead of http) does not work.So to sum up what makes service workers work is:
https://github.com/coder/code-server/blob/main/docs/guide.md#using-lets-encrypt-with-nginx
https://github.com/coder/code-server/blob/main/docs/guide.md#using-lets-encrypt-with-caddy
Web socket fails to connect through Apache #4723 (comment)
code-server --cert /path/to/cert.crt --cert-key /path/to/key.pemlocalhost/127.0.0.1localhost/127.0.0.1localhost/127.0.0.1https://github.com/coder/code-server/blob/main/docs/guide.md#port-forwarding-via-ssh
http://192.168.107.129:8080) as secure origin. HTTPS-URLs may not work!chrome://flags/#unsafely-treat-insecure-origin-as-secureCan/Should we close this issue or should i leave it open till anyone updates the documentation?
[-][Bug]: Markdown preview not working with self signed certificate (SecurityError)[/-][+]Extensions using web views not working with self signed certificate[/+]Add faq entry about web views
Add faq entry about web views