Unable to access external web sites through Squid proxy server with required authentication.

Last post 03-04-2007 6:09 PM by MNF. 1 replies.

Sort Posts:

  • Unable to access external web sites through Squid proxy server with required authentication.

    02-26-2007, 7:00 PM
    • Member
      259 point Member
    • MNF
    • Member since 07-24-2005, 8:15 PM
    • Posts 72
    I have an ASP.NET 2.0 application,that retrieves information from external web sites using different methods, including SOAP web services(e.g Amazon and Google), dataset.ReadXml(url) and HttpWebRequest. GetResponse().

    For clients with proxy servers that required authentication we adding to web.config 

    <defaultProxy enabled="true" useDefaultCredentials="true">

    undefinedproxy bypassonlocal="True" proxyaddress="address

    </

    defaultProxy>

    It works fine with MS ISA and for one our client who use SQUID,but it doesn't work on another site with SQUID proxy server- still returns
    HTTP status 407: Proxy Authentication Required 

    I am able to set proxy details for individual web services proxy with the code like the following

            IWebProxy proxyObject = new WebProxy(txtProxy.Text, true);

    //special case for Basic authentication (from http://www.xmlwebservices.cc/index_FAQ.htm )

            proxyObject.Credentials = new System.Net.NetworkCredential(sUser, sPassword);

            ws.Proxy = proxyObject;

            ws.PreAuthenticate = true;//from http://www.awprofessional.com/articles/article.asp?p=27574&seqNum=3

            ws.AllowAutoRedirect = true;
    and it works, but I prefer to have one centralized solution, that useDefaultCredentials expected to provide.

    Microsoft acknowledged that
    useDefaultCredentials doesn't work for SQUID proxy server , but they fixed it in Visual Studio SP1, not in .Net Framework(actually I haven't try to use .Net framework 3.0 - may be there is a fix for this?).

    At the moment I am planning to add SetProxy functionality for each Web Services call,HttpWebRequest call and replace  dataset.ReadXml(url)  with HttpWebRequest.GetRequesst - boring work.

    Can anyone suggest better solution?

  • Re: Unable to access external web sites through Squid proxy server with required authentication.

    03-04-2007, 6:09 PM
    • Member
      259 point Member
    • MNF
    • Member since 07-24-2005, 8:15 PM
    • Posts 72

    I believe that I understand, why our application has problem using useDefaultCredentials  with SQUID proxy server.
    It seems that .Net sends default credentials in format DOMAIN\UserName (or MACHINE\UserName for local users).

    However SQUID expects just UserName and will not accept "\" in the name, as I was adviced by system administrator:

    "Squid does not allow non-alphanumeric characters in the username so we cant try to fake it and embed a domain in the credentials (it wont take the backslash)."

    I've tried to check, which credentials are sent to proxy server using Network Monitor. Unfortunately, I wasn't able to interprete packets.
    By the way, Network Monitor showed that our web server and Proxy Server use TCP, not HTTP protocol to communicate. Is it normal?

    Could anyone confirm that in case of useDefaultCredentials="true" .Net Runtime sends default credentials in format DOMAIN\UserName (or MACHINE\UserName for local users)????


     

     
Page 1 of 1 (2 items)