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
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
Open code server in Brave Browser
Log in
Read the error message
Expected
Code server should run with all features enabled
Actual
All sorts of random problems, including broken Image display
@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).
I am starting code-server with /usr/local/bin/code-server --cert --bind-addr 0.0.0.0:8080 /app so creating proper certificates should happen automagically...
I am starting code-server with /usr/local/bin/code-server --cert --bind-addr 0.0.0.0:8080 /app so creating proper certificates should happen automagically...
$ code-server --help
[...]
--cert Path to certificate. A self signed certificate is generated if none is provided.
[...]
Error loading webview: Error: Could not register service workers: SecurityError: Failed to register a ServiceWorker for scope
This error has nothing to do but with your certificate and the protocol(http/https) you use. Webview is based on Service Work and Service Work needs https to run
1.As benz0li said above, if you have used --cert param then code-server generates a self-signed cert, if you use https://ip:port to open code server at this point, since no root CA in your browser can verify this self-signed cert, you will get this error. You can either add this self signed cert to trust store or buy a real cert from public organizations.
2.I noticed that you are opening code-server on your local linux machine, I think you can just use http protocol to open it since using service worker via http from localhost are not restricted.
3.You can also use the following params to open your browser to escape cert error(Not secure in public network environment but easy to use if you are using code-server on your local network)
ip and port needed to be replaced start chrome http://192.168.142.129:8080 --ignore-certificate-errors --unsafely-treat-insecure-origin-as-secure=http://192.168.142.129:8080
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
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...
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.
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 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.
The solution worked for me, but you have to generate a certificate with subjectAltName (and your served dns), like this : openssl req -x509 -nodes -days 3650 -newkey rsa:4096 -sha256 -keyout /tmp/self-signed.key -out /tmp/self-signed.crt -addext "subjectAltName=DNS:mydns" otherwise Brave'll still ask for some kind of internal validation
Activity
gogobd commentedon Jul 14, 2022
Maybe related to #4800
benz0li commentedon Jul 20, 2022
@gogobd Almost certainly there is something wrong with your certificates and/or setup.
@jsjoeio This is not a
code-serverbug – 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).benz0li commentedon Jul 21, 2022
@gogobd Have a look at mkcert for making locally-trusted development certificates.
gogobd commentedon Jul 21, 2022
I am starting code-server with
/usr/local/bin/code-server --cert --bind-addr 0.0.0.0:8080 /appso creating proper certificates should happen automagically...gogobd commentedon Jul 21, 2022
benz0li commentedon Jul 21, 2022
$ code-server --help [...] --cert Path to certificate. A self signed certificate is generated if none is provided. [...]ℹ️ When using self-signed certificates, its root CA needs to be added to the (Systems/Braves?) trust store.
👉 See also https://github.com/FiloSottile/mkcert#supported-root-stores
I don't think Brave – as a privacy-focused browser – does support self-signed certificates [by default].
ericzhucode commentedon Aug 9, 2022
This error has nothing to do but with your certificate and the protocol(http/https) you use. Webview is based on Service Work and Service Work needs https to run
1.As benz0li said above, if you have used --cert param then code-server generates a self-signed cert, if you use https://ip:port to open code server at this point, since no root CA in your browser can verify this self-signed cert, you will get this error. You can either add this self signed cert to trust store or buy a real cert from public organizations.
2.I noticed that you are opening code-server on your local linux machine, I think you can just use http protocol to open it since using service worker via http from localhost are not restricted.
3.You can also use the following params to open your browser to escape cert error(Not secure in public network environment but easy to use if you are using code-server on your local network)
ip and port needed to be replaced
start chrome http://192.168.142.129:8080 --ignore-certificate-errors --unsafely-treat-insecure-origin-as-secure=http://192.168.142.129:80803 remaining items
benz0li commentedon Aug 9, 2022
Then the root CA from
mkcertmakes no difference. Because you don't use the certificate generated bymkcertforlocalhost.benz0li commentedon Aug 9, 2022
If you want to use the certificate generated by code-server, you must add the root CA from the Dockerfile to your trust store.
ericzhucode commentedon Aug 9, 2022
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 commentedon Aug 9, 2022
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...
gogobd commentedon Aug 9, 2022
Could I retrieve the generated root certificates from my container and include them in my hosts trust store?
benz0li commentedon Aug 10, 2022
No. This seems to be a limitation of Brave with self-signed certificates.
benz0li commentedon Aug 10, 2022
I do not know. It's better to use
mkcertand do it the other way around.QED
gogobd commentedon Dec 10, 2022
I upgraded to 4.9.0 and this issue is still not solved; the certificate that is being generated on startup doesn't work in Brave.
jsjoeio commentedon Dec 12, 2022
@gogobd are you using Ubuntu 22.04 by chance?
gogobd commentedon Dec 13, 2022
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 #4800).
benz0li commentedon Aug 9, 2023
@gogobd Please close the issue when it is resolved.
gogobd commentedon Aug 9, 2023
Note:
openssl s_client -connect localhost:8480 -showcerts </dev/null 2>/dev/null | sed -n '/-----BEGIN CERTIFICATE-----/,/-----END CERTIFICATE-----/p'shows the certificate ready to be used.bastienjalbert commentedon Nov 19, 2024
The solution worked for me, but you have to generate a certificate with subjectAltName (and your served dns), like this :
openssl req -x509 -nodes -days 3650 -newkey rsa:4096 -sha256 -keyout /tmp/self-signed.key -out /tmp/self-signed.crt -addext "subjectAltName=DNS:mydns"otherwise Brave'll still ask for some kind of internal validation