The Wayback Machine - https://web.archive.org/web/20220522201914/https://github.com/Microsoft/vscode/issues/12588
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

Extension proxy support #12588

Open
CodeZombieCH opened this issue Sep 25, 2016 · 49 comments
Open

Extension proxy support #12588

CodeZombieCH opened this issue Sep 25, 2016 · 49 comments
Assignees
Labels
api feature-request proxy
Milestone

Comments

@CodeZombieCH
Copy link

@CodeZombieCH CodeZombieCH commented Sep 25, 2016

Proxy support for Visual Studio Code has been introduced recently through environment variables/settings (see https://code.visualstudio.com/docs/setup/setup-overview#_proxy-server-support). As an extension developer I would like to use these settings when requesting resources from the internet. My current implementation fails for users using a proxy.

What is the recommended way for an extension to use a proxy?

I could not find a vscode API that exposes methods to make requests using a proxy other than access to the proxy settings (workspace.getConfiguration()) and implementing everything on my own. Looking at the Visual Studio Code code base I identified the code that adds support for proxies, but copy&paste it into my extension would result in duplicated and potentially outdated code, which is something I want to avoid whenever possible. As I am probably not the only extension developer accessing the internet, I would like to hear your opinion on this issue. Any feedback would be greatly appreciated.

@chrmarti chrmarti added feature-request api labels Sep 27, 2016
@jrieken
Copy link
Member

@jrieken jrieken commented Sep 28, 2016

-1 for adding this for to the API but +1 for extracting our code into a node-module. @joaomoreno how feasible is that? how much code do we add on top of other node-modules?

@joaomoreno
Copy link
Member

@joaomoreno joaomoreno commented Sep 28, 2016

It's thin.

@jrieken jrieken removed their assignment Sep 28, 2016
@jrieken jrieken changed the title Expose an API for extensions to use a proxy Make proxy code reusable Sep 28, 2016
@jrieken
Copy link
Member

@jrieken jrieken commented Sep 28, 2016

I leaving it with you then ;-)

@joaomoreno joaomoreno added this to the Backlog milestone Sep 28, 2016
@CodeZombieCH
Copy link
Author

@CodeZombieCH CodeZombieCH commented Sep 28, 2016

A node package sounds like a cool solution. Let me know when it's ready so I can test it and provide feedback.

@joaomoreno
Copy link
Member

@joaomoreno joaomoreno commented Apr 26, 2017

We're going with a different proxy solution in the future, skipping this.

@CodeZombieCH
Copy link
Author

@CodeZombieCH CodeZombieCH commented Apr 26, 2017

Do you have any details about that future solution?

@joaomoreno
Copy link
Member

@joaomoreno joaomoreno commented Apr 26, 2017

Actually, I might've closed this too eagerly.

We're going with using Chrome's network stack for everything. So you're a bit busted. The only way out is exposing an API for making network requests. I'll leave this open for that.

@joaomoreno joaomoreno reopened this Apr 26, 2017
@joaomoreno joaomoreno changed the title Make proxy code reusable Expose network service to extensions Apr 26, 2017
@joaomoreno joaomoreno added api proxy labels Apr 26, 2017
@joaomoreno joaomoreno removed their assignment Jun 19, 2017
@joaomoreno joaomoreno changed the title Expose network service to extensions Extension proxy support Jul 3, 2017
@tebeco
Copy link

@tebeco tebeco commented Dec 4, 2017

@joaomoreno any news from April ?
times to times, We have to set our password in clear so far in the settings json file in order to update OmniSharp

This is insane and quite critical
Everybody tries to point someone else team and it really hurt lots of people using VsCode in companies

@tebeco
Copy link

@tebeco tebeco commented Dec 4, 2017

Do i need to ping more contributor to VsCode in order to get more feedback on it ?

@GigiusB
Copy link

@GigiusB GigiusB commented Feb 19, 2020

I had a progress with this which I believe may be related: after launching "code --verbose" I could see errors like the following:

ERROR:cert_verify_proc_nss.cc(969)] CERT_PKIXVerifyCert for update.code.visualstudio.com

I then followed the instructions at Linux Cert Management in order to add our corporate CA certificate as follows:

certutil -d sql:$HOME/.pki/nssdb -A -t "C,," -n ybs -i $CA_CERT

After relaunching VSCode everything seems working!

@orthoxerox
Copy link

@orthoxerox orthoxerox commented Aug 17, 2020

For those visiting this from a search engine, to make extensions like C# work via an https proxy with authentication, right now you need the following:

  1. You need your proxy with username and password in settings.json: "http.proxy": "https://user:pwd@host:port" (without it you will get error 407)
  2. You need to install win-ca extension from ukoloff
  3. You need "win-ca": "append" in settings.json (without it you will get "Error: self signed certificate in certificate chain")
  4. Don't put anything else proxy or http-related in settings.json

I tested this both in 1.46.1 and 1.48.0 (with auth.js fix)

@tebeco
Copy link

@tebeco tebeco commented Aug 17, 2020

This look like it would be more sustainable to have all of this baked within VsCode, and not at the full charge of extensions developer, and at the cost of consumer security.

Somehow, having an API in VsCode return an HttpClient already setup, and supporting POSSIBLE NTLMv2 / Kerberos look like something acheivable in order to use VsCode safetly.

The equivalent in C# would look like:

public HttpClient GetMeSomethingReady()
{
  var proxyHttpClientHandler = new HttpClientHandler()
  {
    Proxy = new WebProxy("http://FROM_THE_SETTING_NO_CREDENTIALS")
    {
      Credentials = CredentialCache.DefaultNetworkCredentials
    },
    SslProtocols = SslProtocols.Tls13 | SslProtocols.Tls12 | SslProtocols.Tls11 | SslProtocols.Tls,
    UseProxy = true
  };

  return new HttpClient(proxyHttpClientHandler);

then extensions developers would do something like

var httpClient = GetMeSomethingReady();
httpClient.Get(url)

If they want to do everything from scratch ... why not, but it look like this should be

  • out of the box
  • 0 extensions required
  • no password nowhere, as the user is already logged, and already has NTLMv2 / Kerberos ticket
  • use the User Certificate Store on windows build (that's the standard)
  • No env var as this would require special script to run VS not to polute shell session or user session

@chrmarti
Copy link
Contributor

@chrmarti chrmarti commented Aug 17, 2020

@orthoxerox Part of win-ca is already built-in, you shouldn't need to install it separately.

@orthoxerox
Copy link

@orthoxerox orthoxerox commented Aug 17, 2020

@chrmarti I shouldn't, but I had to. "http.systemCertificates": true is the default setting, but it only allows VSCode to download extensions without complaining about self-signed certs, not the extensions to download their dependencies.

@southwood
Copy link

@southwood southwood commented Jan 14, 2021

Here is a workaround that enables extensions to be used in a devcontainer while a mitm solution (such as zscaler) is deployed to your network.

In devcontainer.json:

"remoteEnv": {
    "NODE_EXTRA_CA_CERTS": "<PROVIDE_YOUR_TRUSTED_ROOT_CA_CERT_HERE>.crt"
},
"postCreateCommand": "sed -i -e 's/this\\.strictSSL=/this\\.strictSSL=false\\&\\&/g' $(find ~ -name *HostAgent.js)",

I think root cause is that remoteExtensionHostAgent.js ignores all the existing settings.json files and overrides local container's npm/node configuration by default. Another way to achieve this is to configure http.proxyStringSSL in your local settings.json and then drop that into every subdirectory of the extension runtime find ~ -type d | xargs -I {} cp .vscode/settings.json {}. If anyone knows which specific folder's settings.json is used by remoteExtensionHostAgent.js, that would be a better option than using sed to edit the minified js.

@Glutnix
Copy link

@Glutnix Glutnix commented Oct 6, 2021

Workaround for vscode.github-authentication giving a HTTP error 407 when receiving the authentication token from a browser:

In VSCode Settings, you can set http.proxy to http://username:PASSWORD@your-proxy-ip:port (or https if required) before authenticating
AND REMOVE IT once you verify your username appears in the Accounts button on the Activity Bar.
Plugins like GitLens and Settings Sync don't need to use the proxy once you've done this.

@Szaboadrii22
Copy link

@Szaboadrii22 Szaboadrii22 commented Nov 28, 2021

In VSCode Settings, you can set http.proxy to http://username:PASSWORD@your-proxy-ip:port

@Szaboadrii22
Copy link

@Szaboadrii22 Szaboadrii22 commented Nov 28, 2021

Extension proxy support #12588

@joewood
Copy link

@joewood joewood commented May 22, 2022

One alternative to the suggestion of creating a VSCode fetch API for extensions would be to use the VSCode host as a proxy. VS Code already supports PAC files and NTLM/GSS corporate proxy authentication. Using this networking stack it could expose a port to the extensions like CNTLM. This could be exposed in the form of http_proxy env variables (so no change would be required there). Network requests would then pass through VS Code.

This feels like the simplest approach as it requires no change to extensions (continue to use http_proxy), the code for port forwarding is already in present.

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

No branches or pull requests

Morty Proxy This is a proxified and sanitized view of the page, visit original site.