0

I will state up front that this is a well discussed topic however I have been unable to find the answer I need. I have created a winforms app that makes WCF calls to a server. All works fine with no http proxy as well as an http proxy present (non-authenticating). I did no extra coding to achieve this since many problems with proxies were fixed after .NET 1.1. It just works by accepting the Internet Options (from IE). This is my primary goal. I want the proxy config to "just work" including authentication. Right now, proxy with auth fails. I do not want to programmatically specify credentials, server names, port, etc... It was pointed out here How should I set the default proxy to use default credentials? that the following entry is needed:

<system.net>
<defaultProxy useDefaultCredentials="true" />
</system.net>

I've got this in my app.config but not having success. I'm using squid as my proxy server and I have it setup with Basic authentication. With this setup, I am forced to programmatically provide username/password (don't want this). I know how to do this and I can get it to work but that's not the point. I would like all settings to be discovered including my current credentials I used to authenticate with windows. The following has an interesting answer Web service calls and proxy authentication in the real world. It states that if IE had to prompt for username and password then so would my application. In fact, IE DOES prompt for username and password. I found good info here as well http://blogs.msdn.com/b/stcheng/archive/2008/12/03/wcf-how-to-supply-dedicated-credentials-for-webproxy-authentication.aspx. I'm going wrong somewhere. If Basic Auth is wrong, then what type of authentication would allow everything to "just work".

Cœur
  • 37,241
  • 25
  • 195
  • 267
Jim Kennedy
  • 782
  • 9
  • 23
  • It would be ok to pass the users current creds behind the scenes scenes somehow (and programmatically) without actually "touching" the username and password. This would meet my "just work" requirement. Perhaps something like this: proxy.Credentials = CredentialCache.DefaultCredentials; (although it does work for me) – Jim Kennedy Apr 02 '14 at 13:01
  • That should read: Does NOT work for me. Even though I set the proxy credentials programmatically to CredentialCache.DefaultCredentials I still get a 407 HTTP (proxy auth failure). The user's creds are not passing with this technique. – Jim Kennedy Apr 02 '14 at 15:43

1 Answers1

0

After more research, you really can't do what I'm trying to do across authentication protocols. The following MSDN page http://msdn.microsoft.com/en-us/library/system.net.credentialcache.defaultcredentials.aspx points that out. Understandably, basic auth if very old and not supported for calls to DefaultCredentails according to this page, but I'm deploying to users that might be running XP with older proxy servers. I will have to provide my user base with a manual method to configure user/password for basic auth with a proxy server. I believe what I'm trying to achieve is certainly doable with NTLM and Negotiate type auth methods. The bottom line is you have to manually provide user/password with basic auth with code like this:

WebRequest.DefaultWebProxy.Credentials = new NetworkCredential("user", "password123");
Jim Kennedy
  • 782
  • 9
  • 23