I’m connecting to a web service from .NET, like:
var request = (HttpWebRequest) WebRequest.Create(uri);
request.Credentials = new NetworkCredential("usr", "pwd", "domain");
var response = (HttpWebResponse) request.GetResponse();
The authorization header looks like:
Authorization: Digest username="usr",realm="domain",nonce="...",
uri="/dir",algorithm="MD5",etc...
^^^^^^^^^^
The server returns (400) Bad Request. A header send by Chrome or IE looks like:
Authorization: Digest username="usr", realm="domain", nonce="...",
uri="/dir/query?id=1", algorithm=MD5, etc...
^^^^^^^^^^^^^^^^^^^^^
We suspect that the difference in URI is causing the web service to deny the request with a 400 error. Is it possible to make HttpRequest send out an Authorization header that includes the full URI?
It turns out that Digest authentication is fairly easy to implement. With our own implementation, we were able to use the full URI (including parameters) to generate the MD5 hash. That fixed the problem.
In case someone hits this problem in the future, you can call the workaround like:
The code for the DigestAuthFixer class: