Skip to content

Commit 1330ef5

Browse files
authored
Fix compatibility with NTLM authentication to McAfee Web Gateway (#66305)
1 parent ef74545 commit 1330ef5

File tree

1 file changed

+12
-1
lines changed

1 file changed

+12
-1
lines changed

src/libraries/System.Net.Http/src/System/Net/Http/SocketsHttpHandler/AuthenticationHelper.NtAuth.cs

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -154,8 +154,19 @@ private static async Task<HttpResponseMessage> SendWithNtAuthAsync(HttpRequestMe
154154
NetEventSource.Info(connection, $"Authentication: {challenge.AuthenticationType}, SPN: {spn}");
155155
}
156156

157+
ContextFlagsPal contextFlags = ContextFlagsPal.Connection;
158+
// When connecting to proxy server don't enforce the integrity to avoid
159+
// compatibility issues. The assumption is that the proxy server comes
160+
// from a trusted source. On macOS we always need to enforce the integrity
161+
// to avoid the GSSAPI implementation generating corrupted authentication
162+
// tokens.
163+
if (!isProxyAuth || OperatingSystem.IsMacOS())
164+
{
165+
contextFlags |= ContextFlagsPal.InitIntegrity;
166+
}
167+
157168
ChannelBinding? channelBinding = connection.TransportContext?.GetChannelBinding(ChannelBindingKind.Endpoint);
158-
NTAuthentication authContext = new NTAuthentication(isServer: false, challenge.SchemeName, challenge.Credential, spn, ContextFlagsPal.Connection | ContextFlagsPal.InitIntegrity, channelBinding);
169+
NTAuthentication authContext = new NTAuthentication(isServer: false, challenge.SchemeName, challenge.Credential, spn, contextFlags, channelBinding);
159170
string? challengeData = challenge.ChallengeData;
160171
try
161172
{

0 commit comments

Comments
 (0)