468,292 Members | 1,445 Online
Bytes | Developer Community
New Post

Home Posts Topics Members FAQ

Post your question to a community of 468,292 developers. It's quick & easy.

WebProxy + SSL

Hi, all

I have a problem of the following kind.

There's a remote server that can be accessed via HTTPS (say,
https://remoteserver). This server doesn't allow anonymous users, so I have
to connect to it using some username/password.

There's a .NET client that must access this remote server and this client
can go to the Internet only through Proxy Server. This Proxy Server doesn't
require authentication.

And now what happens: .Net client doesn't work properlym receiving
401-Unauthorized while trying to connect to remote server.

However:

1. Running IE from the same client machine (and using the same Proxy
Server), user can connect to remote server just fine
2. If .NET client is configured to bypass proxy server, it can connect to
remote server just fine
3. .NET client can connect (via Proxy Server) to the same remote server via
http.
4. .NET client can connect (via Proxy Server) to any other https site if it
allows anonymous access.

Taking above into account, it seems that the problem is with passing the
credentials through Proxy Server. Does anyone have ideas?

Now here's the code:

string url = "https://remoteserver";
string proxyurl = "some.proxyserver.url:8080";
NetworkCredential c = new NetworkCredential("user", "password", "domain");
try
{
WebProxy p = new WebProxy(proxyurl, false);
p.Credentials = CredentialCache.DefaultCredentials;
HttpWebRequest req = (HttpWebRequest)HttpWebRequest.Create(url);
req.Proxy = p;
req.Credentials = c;
req.PreAuthenticate = true;
req.KeepAlive = true;
using(HttpWebResponse resp = (HttpWebResponse)req.GetResponse())
{
Console.WriteLine(resp.StatusCode);
}
}
catch(Exception ex)
{
Console.WriteLine(ex);
}

May 8 '06 #1
0 915

This discussion thread is closed

Replies have been disabled for this discussion.

Similar topics

1 post views Thread by Jim Douglas | last post: by
2 posts views Thread by Ricardo Luceac | last post: by
4 posts views Thread by vooose | last post: by
2 posts views Thread by Sam Santiago | last post: by
reply views Thread by Michael S. Scherotter | last post: by
4 posts views Thread by Andrew | last post: by
3 posts views Thread by =?Utf-8?B?TXJOb2JvZHk=?= | last post: by
reply views Thread by NPC403 | last post: by
reply views Thread by Teichintx | last post: by
By using this site, you agree to our Privacy Policy and Terms of Use.