Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Register a non-standard LSP content request for resolving schemas on the client side #359

Merged
merged 2 commits into from
Nov 26, 2020

Conversation

JPinkney
Copy link
Contributor

@JPinkney JPinkney commented Nov 20, 2020

Signed-off-by: Josh Pinkney [email protected]

What does this PR do?

This PR registers a non-standard LSP request used specifically for VSCode. This LSP request gets triggered when an HTTP/HTTPS request to a schema is being made. Instead of the server resolving the schema the language server will send the URI to the client-side to be resolved. This has to be done in order to circumvent signed certificate errors that happen when you are trying to fetch the schemas outside of VSCode. From my understanding, VSCode is using Electron which uses Chromium which has certs already installed so this is why we have to do it this way and can't just fetch the schemas normally. I assume this is also why vscode-json-languageservice does the same thing

What issues does this PR fix or reference?

redhat-developer/vscode-yaml#107

Is it tested? How?

The only way I know how to test this is on the Red Hat VPN.

You'll need the client-side changes: redhat-developer/vscode-yaml#395

Once you connect to the VPN these schemas should resolve correctly

"yaml.schemas": {
    "https://gitlab.cee.redhat.com/cpaas/service/-/raw/development/resources/schemas/release-root.json": "release.yml",
    "https://gitlab.cee.redhat.com/cpaas/service/-/raw/development/resources/schemas/product-root.json": "product.yml"
  }

…s LSP request

gets triggered when an HTTP/HTTPS request to a schema is being made. Instead of the
server resolving the schema the language server will send the URI to the client side
to be resolved. This has to be done in order to circumvent signed certificate
errors that happen when you are trying to fetch the schemas outside of VSCode.

Signed-off-by: Josh Pinkney <[email protected]>
Signed-off-by: Josh Pinkney <[email protected]>
@coveralls
Copy link

coveralls commented Nov 20, 2020

Coverage Status

Coverage decreased (-0.3%) to 79.275% when pulling c07059b on content-request into 33b090a on master.

@evidolob
Copy link
Collaborator

From my understanding, VSCode is using Electron which uses Chromium which has certs already installed so this is why we have to do it this way and can't just fetch the schemas normally.

That is true, but only for main vscode code, all extensions works in regular Node.JS instance, which spawn from Electron process. Maybe VSCode has some code which set up cert for extensions node.js process. Need to look on that.

@JPinkney
Copy link
Contributor Author

Hmm, it looks like ps aux only shows the language server's running in their own process, I can't find any of the client-side side stuff. Do you know of any way to find the VSCode extension client-side process?

@evidolob
Copy link
Collaborator

evidolob commented Nov 20, 2020

Yes, try ps -ax | grep bootstrap-fork and look on --type=extensionHost option.
Link on source
It seems that they use fork function to spawn process for extensions.

@JPinkney
Copy link
Contributor Author

@aeschli I see that you brought the json schema fetching for http and https into the ext host quite a long time ago (microsoft/vscode@849d941), was your reasoning because of self-signed certificates like ours? User's keep running into self signed certificate issues and I'm not sure of a clear way to resolve this other then grabbing the schemas from the extension host as well

@evidolob
Copy link
Collaborator

@JPinkney I made some investigation on this.
According to doc VSCode uses Chromium mechanisms to work with TLS.
It seems that this PR is only reliable way to handle the situation with VPN or self signed certificates.

What is still currius for me, that vscode run extensions and yaml-ls in same buildin node.js (in different process) with fork function. So for me, is still unclear, what make the difference in https requests.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants