Re: httpwebrequest with https behind proxy with authentication



Hi to all,
after searching and searching perhaps I have found the problem, it is documented in Microsoft KB928563. Can anyone who has access to the hotfixes confirm this?
Regards,
Andrea Pierini

"Andrea Pierini" <andrea_maticad@xxxxxxxxxxxxx> wrote in message news:A83DD1A4-8C6C-4653-AF56-31D5F6C027CE@xxxxxxxxxxxxxxxx
Hi Steven,
first of all thanks for your answer.
Our proxy server uses NTLM authentication and as you suggested I modified the code as follows:

*******************************
WebRequest req = WebRequest.Create("https://www.domus3d.com/ws/test.txt";);
Uri proxyuri = new Uri("http://192.168.0.6:3128";);
WebProxy proxy = new WebProxy(proxyuri, true);
NetworkCredential cred = new NetworkCredential("administrator", "xxxxx", "WEBSERVER12");
CredentialCache credcache = new CredentialCache();
credcache.Add(proxyuri, "NTLM", cred);
proxy.UseDefaultCredentials = false;
proxy.Credentials = credcache;
req.Proxy = proxy;
WebResponse res = req.GetResponse();
*******************************

I still receive "The remote server returned an error: (407) Proxy Authentication Required." and it works if I use http instead of https or if I disable authentication on the proxy (I can do it to make some tests, but our customers can't). This is the proxy server log:

*******************************
1197019352.005 0 192.168.0.250 TCP_DENIED/407 2108 CONNECT www.domus3d.com:443 - NONE/- text/html
1197019425.021 73000 192.168.0.250 TCP_MISS/200 3322 CONNECT www.domus3d.com:443 webserver12\administrator DIRECT/62.149.195.31 -
1197019632.552 0 192.168.0.250 TCP_DENIED/407 1839 GET http://www.domus3d.com/ws/test.txt - NONE/- text/html
1197019632.568 0 192.168.0.250 TCP_DENIED/407 2153 GET http://www.domus3d.com/ws/test.txt - NONE/- text/html
1197019632.599 31 192.168.0.250 TCP_HIT/200 464 GET http://www.domus3d.com/ws/test.txt webserver12\administrator NONE/- application/octet-stream
1197021220.771 39422 192.168.0.250 TCP_MISS/200 3466 CONNECT www.domus3d.com:443 webserver12\administrator DIRECT/62.149.195.31 -
*******************************

Line #1 is the .Net code trying to access the file over https (doesn't work); line #2 is FireFox successfully accessing the file over https; line #3/4/5 is the .Net code successfully accessing the file over http; line #6 is Internet Explorer successfully accessing the file over https. It seems that the .Net code doesn't pass the proxy authentication over HTTP CONNECT.

Any idea?

Thanks in advance,
Andrea Pierini



"Steven Cheng[MSFT]" <stcheng@xxxxxxxxxxxxxxxxxxxx> wrote in message news:0dEVtUIOIHA.7908@xxxxxxxxxxxxxxxxxxxxxxxxx
Hi Andrea,

From your description, you're using WebRequest component to download a file
from a remote webservice. That webservice is accessed through a proxy and
the proxy also require authentication. However, you found your webservice
client always get proxy authentication error, correct?

Based on the code snippet you provided, you directly create a
NetworkCredential (with username/password pair) and send it via
WebProxy.Credentials. One potential things here is that whether you've
confirmed what kind of Authentication Type is the webproxy using?
Integrated windows or basic or ...?

Generally, when sending credential through NetworkCredential, it is
recommended that you explicitly supply the authenticationType(via
CredentialCache class). e.g.

=========
CredentialCache cache = new CredentialCache();
cache.Add( new Uri(proxy.Url),
// Web service URL
"Negotiate",
// Kerberos or NTLM
new NetworkCredential("username", "password", "domainname")
);

proxy.Credentials = cache;
=========

the following thread has also mentioned this:

http://forums.microsoft.com/MSDN/ShowPost.aspx?PostID=1772251&SiteID=1

You can try looking at this to see whether this is the cause.

BTW, also check the behavior when you visit it in IE(whether there is any
warning or error you interactively ignore), since any interactively
ignorable error will cause exception in programamtic code.

Sincerely,

Steven Cheng

Microsoft MSDN Online Support Lead



==================================================

Get notification to my posts through email? Please refer to
http://msdn.microsoft.com/subscriptions/managednewsgroups/default.aspx#notif
ications.



Note: The MSDN Managed Newsgroup support offering is for non-urgent issues
where an initial response from the community or a Microsoft Support
Engineer within 1 business day is acceptable. Please note that each follow
up response may take approximately 2 business days as the support
professional working with you may need further investigation to reach the
most efficient resolution. The offering is not appropriate for situations
that require urgent, real-time or phone-based interactions or complex
project analysis and dump analysis issues. Issues of this nature are best
handled working with a dedicated Microsoft Support Engineer by contacting
Microsoft Customer Support Services (CSS) at
http://msdn.microsoft.com/subscriptions/support/default.aspx.

==================================================


This posting is provided "AS IS" with no warranties, and confers no rights.








--------------------
From: "Andrea Pierini" <andrea_maticad@xxxxxxxxxxxxx>
Subject: httpwebrequest with https behind proxy with authentication
Date: Thu, 6 Dec 2007 16:26:19 +0100

Hi to all,
I have a problem to download a file with httpwebrequest when

_ https protocol is used
_ the client is behind a proxy that requires authentication

For example consider the following code:

WebRequest req =
WebRequest.Create("https://www.domus3d.com/ws/test.txt";);
req.Proxy = new WebProxy("http://192.168.0.6:3128";, true); //
Proxy available at IP 192.168.0.6 on port 3128
req.Proxy.Credentials = new NetworkCredential("user", "pwd",
"domain"); // Proxy network credentials
WebResponse res = req.GetResponse();

I always receive "The remote server returned an error: (407) Proxy
Authentication Required.". What's wrong? Note that if I make the request
over http the code works and with Internet Explorer I can open the file
either over http or over https.

Thanks in advance for any help,
Andrea Pierini

PS: I've seen that many users experience the same problem with WSUS 3.0
behind a proxy with authentication





.



Relevant Pages

  • Re: httpwebrequest with https behind proxy with authentication
    ... contact Microsoft Customer Support ... httpwebrequest with https behind proxy with authentication ... Our proxy server uses NTLM authentication and as you suggested I ...
    (microsoft.public.dotnet.framework)
  • Re: Other services through proxy...
    ... Windows Integrated Authentication which thos OS's cannot do. ... browser's proxy settings have a place to supply credentials then that "may" ... The views expressed, are my own and not those of my employer, or Microsoft, ... Understanding the ISA 2004 Access Rule Processing ...
    (microsoft.public.isa)
  • Re: httpwebrequest with https behind proxy with authentication
    ... Our proxy server uses NTLM authentication and as you suggested I modified the code as follows: ... I still receive "The remote server returned an error: Proxy Authentication Required." ... and it works if I use http instead of https or if I disable authentication on the proxy ...
    (microsoft.public.dotnet.framework)
  • RE: httpwebrequest with https behind proxy with authentication
    ... the proxy also require authentication. ... Microsoft MSDN Online Support Lead ... httpwebrequest with https behind proxy with authentication ...
    (microsoft.public.dotnet.framework)
  • Re: Compact Framework: https through proxy server
    ... Devp Support - Windows Embedded ... Produced By Microsoft MimeOLE V6.00.2800.1409 ... | I am using the Proxy property. ... |> to access a https site via proxy. ...
    (microsoft.public.dotnet.framework)