Skip to content

[Bug]: Image not showing up #4800

Closed
Closed

Description

@gogobd

Is there an existing issue for this?

  • I have searched the existing issues

OS/Web Information

  • Web Browser: Brave
  • Local OS: MacOS Monterey
  • Remote OS: debian
  • Remote Architecture: amd54
  • code-server --version: 4.0.1 735c6da

Steps to Reproduce

  1. run code-server --bind-addr 0.0.0.0:443 --cert -- /app
  2. Connect to the address
  3. Click an image

Expected

Image should be shown in editor

Actual

An SSL certificate error occurred when fetching the script.
log.ts:313 ERR [Service Worker] registration DOMException: Failed to register a ServiceWorker for scope ('https://--server--/') with script ('https://--server--/service-worker.js'): An SSL certificate error occurred when fetching the script.

Logs

No response

Screenshot/Video

No response

Does this issue happen in VS Code?

  • I cannot reproduce this in VS Code.

Are you accessing code-server over HTTPS?

  • I am using HTTPS.

Notes

Please note i'm running it in docker but 443 is exposed (via 8080 in my case).

This is a re-opening of #4658

Activity

  1. added
    bugSomething isn't working
    triageThis issue needs to be triaged by a maintainer
    on Jan 27, 2022
  2. gogobd commented on Jan 27, 2022

    @gogobd
    Author

    Additionally "Cannot reconnect. Please reload the window." pops up after some minutes... that's probably related.

  3. jsjoeio commented on Jan 27, 2022

    @jsjoeio
    Contributor

    I was able to reproduce this locally on macOS + Brave with code-server --bind-addr 0.0.0.0:443 --cert

    image

    Error loading webview: Error: Could not register service workers: SecurityError: 
    Failed to register a ServiceWorker for scope ('https://localhost/webview/6659afd9-08e4-4b14-9528-570c9d7107cc/') with script 
    ('https://localhost/webview/6659afd9-08e4-4b14-9528-570c9d7107cc/service-worker.js?id=a8c6338a-43f4-450a-a373-44c7b0e0d34a&swVersion=2&extensionId=&platform=browser&vscode-resource-base-authority=vscode-resource.vscode-webview.net&parentOrigin=https%3A%2F%2Flocalhost'): 
    An SSL certificate error occurred when fetching the script..

    @code-asher any ideas on where to troubleshoot the cause of this? I haven't spent much time generating SSL certificates locally before. I wonder what broke there.

  4. removed
    triageThis issue needs to be triaged by a maintainer
    on Jan 27, 2022
  5. enric1994 commented on Feb 2, 2022

    @enric1994

    In the meantime, you can use version 3.9.1 if you really have to display images:

    docker pull codercom/code-server:3.9.1

  6. code-asher commented on Feb 8, 2022

    @code-asher
    Member

    Seems likely to be the same issue as #4693 (comment)

  7. gogobd commented on Feb 12, 2022

    @gogobd
    Author

    I updated to version 4.0.2 and this issue seems to be fixed!

  8. enric1994 commented on Feb 12, 2022

    @enric1994

    Still not working for me. I have the following setup:

    docker-compose.yml:

    vscode:
        image: codercom/code-server:4.0.2
        ports:
          - "8080:8080"
        volumes:
          - ../:/desk/
          - ./:/home/coder/.config/code-server/
        restart: always
        user: "1000:1000"
    

    config.yaml:

    bind-addr: 127.0.0.1:8080
    auth: password
    password: 1234
    cert: false
    

    I access it using a tunnel (Ngrok)

  9. gogobd commented on Feb 13, 2022

    @gogobd
    Author

    I realised that it did work when docker was running on the same machine, but not when code server was on another machine. Reopening.

  10. reopened this on Feb 13, 2022
  11. 17 remaining items

  12. gogobd commented on Apr 19, 2022

    @gogobd
    Author

    @jsjoeio I always have to confirm that I want to accept the certificate:

    Screenshot 2022-04-19 at 20 56 56

    After confirming the browser marks it as not secure:

    Screenshot 2022-04-19 at 20 59 09

    I run code-sever in docker using `--cert' :

    CMD ~/.local/bin/code-server --cert --bind-addr 0.0.0.0:8080 /app

  13. jsjoeio commented on Apr 19, 2022

    @jsjoeio
    Contributor

    Thanks for the details! That part sounds like it's working as expected 🤔 We'll have to dig into this.

  14. gogobd commented on May 16, 2022

    @gogobd
    Author

    I was wondering if there's any news on this...

  15. jsjoeio commented on May 19, 2022

    @jsjoeio
    Contributor

    Unfortunately not :( I've been pulled onto another project so my code-server work as slowed down this month. Hopefully soon though! PRs/help welcome though

  16. benz0li commented on Jul 21, 2022

    @benz0li
    Contributor

    @gogobd Have a look at mkcert for making locally-trusted development certificates.

  17. gogobd commented on Jul 21, 2022

    @gogobd
    Author

    This could all be the same problem, I'm using "--cert", see #5338

  18. gogobd commented on Dec 10, 2022

    @gogobd
    Author

    I updated to 4.9.0 and it seems to me that the certificates that are being generated on startup are not valid for brave, it shows
    Screenshot 2022-12-10 at 12 52 04
    after accepting the exception. Safari shows a lock sign indicating valid encryption, but it does show images. However Python Notebooks are displayed as text, but that's another issue. Is it not possible to automatically generate a certificate on startup that can be manually accepted in Chrome based browsers?

  19. jsjoeio commented on Dec 12, 2022

    @jsjoeio
    Contributor

    I think something changed in Chromium that prevents it from accepting self-signed certificates or something 🤔

    cc @code-asher do you remember where we read that?

  20. gogobd commented on Dec 13, 2022

    @gogobd
    Author

    I was trying to allow insecure certificates from localhost with chrome://flags/#allow-insecure-localhost but that didn't enable web-views.

  21. gogobd commented on Dec 13, 2022

    @gogobd
    Author

    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.

    This might also be an acceptable workaround for #5338 .

  22. code-asher commented on Dec 19, 2022

    @code-asher
    Member

    Yeah if I recall correctly it will unequivocally refuse certificates it deems insecure for web workers (which are used by web views). Other browsers like Firefox are OK using it for web workers as long as you accept the initial prompt.

  23. benz0li commented on Aug 9, 2023

    @benz0li
    Contributor

    @gogobd Please close the issue when it is resolved.

  24. gogobd commented on Aug 9, 2023

    @gogobd
    Author

    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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't workinghigh-priorityThis issue needs to be resolved ASAP

    Type

    No type

    Projects

    No projects

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions