Skip to content
This repository has been archived by the owner on Jan 23, 2023. It is now read-only.
/ corefx Public archive

[release/3.0] Fix SocketsHttpHandler proxy auth for 'Negotiate' scheme #39981

Merged
merged 1 commit into from
Aug 5, 2019

Conversation

davidsh
Copy link
Contributor

@davidsh davidsh commented Aug 2, 2019

Port of PR #39933 to release/3.0

Issue #39887 reported that proxy authentication with 'Negotiate' scheme broke between
.NET Core 3.0 Preview 6 and Preview 7. The base64 blob was no longer using SPNEGO protocol
but instead was always using NTLM. While 'Negotiate' scheme can use either SPNEGO or NTLM,
it should always use SPNEGO if possible. And many enterprises have a setting which requires
it and rejects NTLM protocol.

This issue was caused by PR #38465 which fixed some other SPN issues with Kerberos
authentication. That PR regressed the SPN calculation for the proxy authentication by
using the wrong host name in the SPN. A mismatch of the SPN will cause NTLM to be used
instead of SPNEGO.

The fix is to check if proxy authentication is being used instead of server authentication.
If so, it ignores any 'Host' header and always will use the uri, which in this case is the
uri of the proxy server.

This was tested manually. It is impossible right now to test Kerberos and proxy scenarios in
CI because they require machine configuration to register SPNs in a Windows Active Directory
environment.

This PR will be ported for release/3.0 for ASK mode consideration since it affects a mainline
enterprise scenario.

Fixes #39887

Issue #39887 reported that proxy authentication with 'Negotiate' scheme broke between
.NET Core 3.0 Preview 6 and Preview 7. The base64 blob was no longer using SPNEGO protocol
but instead was always using NTLM. While 'Negotiate' scheme can use either SPNEGO or NTLM,
it should always use SPNEGO if possible. And many enterprises have a setting which requires
it and rejects NTLM protocol.

This issue was caused by PR dotnet#38465 which fixed some other SPN issues with Kerberos
authentication. That PR regressed the SPN calculation for the proxy authentication by
using the wrong host name in the SPN. A mismatch of the SPN will cause NTLM to be used
instead of SPNEGO.

The fix is to check if proxy authentication is being used instead of server authentication.
If so, it ignores any 'Host' header and always will use the uri, which in this case is the
uri of the proxy server.

This was tested manually. It is impossible right now to test Kerberos and proxy scenarios in
CI because they require machine configuration to register SPNs in a Windows Active Directory
environment.

This PR will be ported for release/3.0 for ASK mode consideration since it affects a mainline
enterprise scenario.

Fixes #39887
@davidsh davidsh added tenet-compatibility Incompatibility with previous versions or .NET Framework area-System.Net.Http.SocketsHttpHandler labels Aug 2, 2019
@davidsh davidsh added this to the 3.0 milestone Aug 2, 2019
@davidsh davidsh self-assigned this Aug 2, 2019
@davidsh
Copy link
Contributor Author

davidsh commented Aug 2, 2019

Description

Fix SocketsHttpHandler proxy auth for 'Negotiate' scheme.

Customer Impact

Customers using an authenticating proxy using Negotiate/Kerberos in their network are unable to send any requests.

Regression?

Yes. This regressed from .NET Core 3.0 Preview 6 to Preview 7 due to PR #38465

Risk

Low risk.

Test changes in this PR

Added new unit test to verify that Negotiate authentication to a proxy will use Kerberos token and not NTLM tokens.

@davidsh
Copy link
Contributor Author

davidsh commented Aug 4, 2019

cc: @danmosemsft

@wtgodbe
Copy link
Member

wtgodbe commented Aug 5, 2019

This was approved by tactics for preview8, merging

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
tenet-compatibility Incompatibility with previous versions or .NET Framework
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants