vscode-js-debug icon indicating copy to clipboard operation
vscode-js-debug copied to clipboard

Sources don't appear on HTTPS website with self-signed certificate

Open digeff opened this issue 6 years ago • 6 comments

How to reproduce:

  • Create an ASP.NET Website with HTTPS and use a self-signed certificate

What happens:

  • We don't get the loaded sources events

Why is this happening: source.toDap() never returns because await this._existingAbsolutePath never returns because verifyFile never returns because send never returns because we get these exceptions: It might be related to this exception:

Exception has occurred: Error
Error: write EPIPE
    at ChildProcess.target._send (internal/child_process.js:741:20)
    at ChildProcess.target.send (internal/child_process.js:625:19)
    at send (vscode-pwa\src\common\hash\index.ts:43:6)
    at Object.exports.verifyFile (vscode-pwa\src\common\hash\index.ts:71:10)
    at Object.checkContentHash (vscode-pwa\src\common\sourceUtils.ts:286:15)
    at new Source (vscode-pwa\src\adapter\sources.ts:141:46)
    at SourceContainer.addSource (vscode-pwa\src\adapter\sources.ts:584:20)


    Exception has occurred: Error
Error: unable to verify the first certificate
    at TLSSocket.onConnectSecure (_tls_wrap.js:1047:34)
    at TLSSocket.emit (events.js:182:13)
    at TLSSocket._finishInit (_tls_wrap.js:629:8)

digeff avatar Feb 04 '20 17:02 digeff

I think the solution here is to install the cert as trusted on your machine. Or perhaps we allow users to provide their CA. While possible to disable certificate verification in Node, doing so is dangerous and generally advised against.

connor4312 avatar Feb 04 '20 17:02 connor4312

The self-signed cert is installed on my machine when I reproduce this issue.

digeff avatar Feb 04 '20 17:02 digeff

Ah, I see. Looks like node has its own CA pool different from the host machine. I think the right fix then is allowing people to provide custom CA cert/s to be applied in addition to Node's tls.rootCertificates.

In VS Code I'll probably have this be a user setting applied to the launch config in the configuration provider, since most users are probably going to have a single self-signed cert for multiple local projects.

connor4312 avatar Feb 04 '20 18:02 connor4312

This scenario works fine on v1. Any idea what changed?

digeff avatar Feb 04 '20 19:02 digeff

I actually don't have any problem running with a trusted self-signed cert on OSX. Maybe this is related to the first error which Eric's PR fixes https://github.com/microsoft/vscode-js-debug/pull/294. Could you try again with that fix applied?

connor4312 avatar Feb 04 '20 19:02 connor4312

This works with the latest fixes! Thanks! :)

digeff avatar Feb 05 '20 23:02 digeff