How to specify a user id and password for Visual S

2019-02-04 14:58发布

How to specify a user id and password for Visual Studio Code with an authenticating proxy?

I've seen the Proxy Server Support on the main VS Code site, but this only mentions two settings ...

"http.proxy": "http://10.203.0.1:5187/"
"http.proxyStrictSSL": false

I've set these, but still no luck, e.g. I can't install extensions ... can't even get a list of them

I suspect it's our proxy, as it needs a user id and password :-(

So how can you set these values?

6条回答
三岁会撩人
2楼-- · 2019-02-04 15:02

My favorite response here is David Martin's suggestion of using Fiddler. But in case that is not something you want to undertake, below is how to set your credentials for the proxy.

To specify DOMAIN + username + password: (It will likely not work with a slash, so use %5C in the place of the slash as shown below)

// The proxy setting to use. If not set will be taken from the http_proxy and https_proxy environment variables
"http.proxy": "http://DOMAIN%5Cusername:password@proxy_name_or_ip:port",
"https.proxy": "http://DOMAIN%5Cusername:password@proxy_name_or_ip:port",

// Whether the proxy server certificate should be verified against the list of supplied CAs.
"http.proxyStrictSSL": false,

To specify just username + password:

// The proxy setting to use. If not set will be taken from the http_proxy and https_proxy environment variables
"http.proxy": "http://username:password@proxy_name_or_ip:port",
"https.proxy": "http://username:password@proxy_name_or_ip:port",

// Whether the proxy server certificate should be verified against the list of supplied CAs.
"http.proxyStrictSSL": false,
查看更多
迷人小祖宗
3楼-- · 2019-02-04 15:13

Please take ref to this article. https://taeguk.co.uk/blog/working-in-visual-studio-behind-the-firewall/

Let’s assume my NTLM login is DOMAIN\User Name and my password is P@ssword! The format for the credentials needs to be DOMAIN\User Name:P@ssword!, but you need to URL Encode the user name and password. A simple online URL encoded can translate your username and password to: DOMAIN%5CUser%20Name and P%40ssword!. Piece all this info into a single string like so: http://DOMAIN%5CUser%20Name:P%40ssword!@proxy-cluster.fqdn.local:8881 Then add this into your User Settings in File, Preferences against the "http.proxy" value: // Place your settings in this file to overwrite the default settings { "http.proxy": "http://DOMAIN%5CUser%20Name:P%40ssword!@proxy-cluster.fqdn.local:8881" }

查看更多
Emotional °昔
4楼-- · 2019-02-04 15:16

If you don't want to store your credentials in the settings file, fiddler can be used to proxy the call to the proxy. Furthermore, I believe the above only works for proxy servers using basic authentication, the following should work for NTLM.

VSCode Open Settings File:

%APPDATA%\Code\User\settings.json

add the following:

{
    "http.proxy": "http://127.0.0.1:8888",
    "http.proxyStrictSSL": false
}

Fiddler Confirm fiddler settings:

enter image description here enter image description here

Fiddler Ensure Fiddler set to automatically authenticate:

enter image description here

VSCode Extensions should now be online:

enter image description here


Update

This is now no longer required following implementation of PR #22369 which was implemented in version 1.15 Proxy server authentication.

In my case I still needed to add:

"http.proxyStrictSSL": false
查看更多
不美不萌又怎样
5楼-- · 2019-02-04 15:17

The venerable CNTLM could help you. You give it your credentials, tell it about the upstream proxy, run it on your local machine, then point VS to the proxy at http://localhost:3128.

http://cntlm.sourceforge.net/

It's a handy solution for any application that doesn't support authenticated proxies.

查看更多
姐就是有狂的资本
6楼-- · 2019-02-04 15:18

Set credentials inside the proxy url:

http://username:password@10.203.0.1:5187/
查看更多
何必那么认真
7楼-- · 2019-02-04 15:18

"http.proxy": "http://DOMAIN//USER:PASSWORD@wsg.test.com:8080". Do not forget to add the port.

查看更多
登录 后发表回答