Skip to content

NTLM credentials not sent by client when there are multiple WWW-Authenticate headers #17545

@aplex

Description

@aplex

We have a strange case after migrating from RC1 to RC2. We use HttpClient with default windows credentials authentication. The code works fine with one server, but does not work with another server. In the second case client just receives 401 error and does not start NTLM handshake.

The only difference that I spotted was that second server sends two WWW-Authenticate headers (one with basic, another with HTML).

When I intercepted the response with Fiddler, and removed "WWW-Authenticate" header with basic authorization, everything worked fine, client started NTLM handshake, and finally authorized.

var handler = new HttpClientHandler();
handler.UseDefaultCredentials = true;            
var client = new HttpClient(handler);
HttpResponseMessage response = await client.GetAsync(url);

Request/response from second server:

GET https://my-server:8081/tfs/DefaultCollection/_apis/projects?api-version=1.0 HTTP/1.1
Connection: Keep-Alive
Accept-Encoding: gzip, deflate
Host: my-server:8081


HTTP/1.1 401 Unauthorized
Content-Type: text/html
Server: Microsoft-IIS/8.5
Access-Control-Allow-Origin: *
Access-Control-Max-Age: 3600
Access-Control-Allow-Methods: OPTIONS,GET,POST,PATCH,PUT,DELETE
Access-Control-Expose-Headers: ActivityId,X-TFS-Session,X-MS-ContinuationToken
Access-Control-Allow-Headers: authorization
X-FRAME-OPTIONS: SAMEORIGIN
Set-Cookie: Tfs-SessionId=XXX; path=/; secure
Set-Cookie: Tfs-SessionActive=2016-06-07 20:44:23Z; path=/; secure
WWW-Authenticate: Basic realm="my-server"
WWW-Authenticate: NTLM
P3P: CP="CAO DSP COR ADMa DEV CONo TELo CUR PSA PSD TAI IVDo OUR SAMi BUS DEM NAV STA UNI COM INT PHY ONL FIN PUR LOC CNT"
X-Content-Type-Options: nosniff
Date: Tue, 07 Jun 2016 20:44:22 GMT
Content-Length: 1293

OS: windows 10 x64, app running on coreclr RC2

Metadata

Metadata

Assignees

Type

No type

Projects

No projects

Milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions