microsoft / microsoft/vscode-dwarf-debugging-ext

I can't fetch the wasm file, error for self-signed certificate

Open
#12 0 comments 2 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Dominant language
JavaScript
Stars
26
Forks
6
PR merge metrics
No merged PRs in 30d

Description

While working on a webassembly application (C++ and emscripten), I use https with a self signed certificate added to the keychain for development. It works well in Google Chrome devtools, but it does not work in vscode + WebAssembly DWARF Debugging.
The reason is that fetch returns a certificate error.
I also tried generating a CA self-signed certificate and a child certificate, but that didn't work either.
I have seen that similar issues exist in other extensions and that potential fixes are in them, not in vscode itself, so I'm reporting it here.
The problem for me occurs on Mac OS, because there is no easier way to add a self-signed certificate to SystemRoot.keychain (unlike linux).
I also tried using that extension, but without success: Mac CA VSCode.

When I updated the enableFetchToLoadFileUris function in worker.js file and add some logs like:

      return originalFetch(...args).catch((err)=>{
        console.error(`[DTM.fetch] FAIL`, { args, err });
        throw err;
      }).then((response) => {
        console.log(`[DTM.fetch] done`, { args });
        return response;
      });

then I get this error log:

[DTM.fetch] FAIL {
  args: [
    'https://local-server-test.dev/some.wasm',
    { mode: 'no-cors' }
  ],
  err: TypeError: fetch failed
      at node:internal/deps/undici/undici:13392:13
      at process.processTicksAndRejections (node:internal/process/task_queues:95:5)
      at async ResourceLoader.fetchSymbolsData (/Users/damian/.vscode/extensions/ms-vscode.wasm-dwarf-debugging-1.0.1/dwarf-debugging/worker.js:10115:29)
      at async ResourceLoader.loadSymbols (/Users/damian/.vscode/extensions/ms-vscode.wasm-dwarf-debugging-1.0.1/dwarf-debugging/worker.js:10144:45)
      at async DWARFLanguageExtensionPlugin.newModuleInfo (/Users/damian/.vscode/extensions/ms-vscode.wasm-dwarf-debugging-1.0.1/dwarf-debugging/worker.js:9514:55) {
    [cause]: Error: unable to verify the first certificate
        at TLSSocket.onConnectSecure (node:_tls_wrap:1677:34)
        at TLSSocket.emit (node:events:518:28)
        at TLSSocket._finishInit (node:_tls_wrap:1076:8)
        at ssl.onhandshakedone (node:_tls_wrap:862:12) {
      code: 'UNABLE_TO_VERIFY_LEAF_SIGNATURE'
  }  }}

The workaround is to set the variable before start vscode, but this is inconvenient and almost impossible in a larger team:

export NODE_EXTRA_CA_CERTS=/path/to/my-ca.pem
open -a "Visual Studio Code"
  • The ideal solution would be for vscode / or this extension to load certificates from Login.keychain / System.keychain.
  • A worse solution, but still satisfactory, would be to allow specifying the path to the certificate's ca in the settings of this extension.

Let me know if I can be of any further help, and thanks in advance!
(This issue is probably similar to this one: https://github.com/microsoft/vscode-dwarf-debugging-ext/issues/8)

Contributor guide

No contributing guide indexed for this repository

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Read worker.js around enableFetchToLoadFileUris and the fetch path shown in the stack trace, then compare the related issue #8. The issue describes certificate failures on macOS and the NODE_EXTRA_CA_CERTS workaround. Done means the extension can fetch the WASM file using a supported certificate configuration without requiring that environment workaround.

Written by the indexing model from the issue text.

Assessment

Tech stack
cpp, javascript, wasm
Domain
devtools, security
Issue type
Bug
Difficulty
5/5
Estimated time
Over a week
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
35/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.