Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Use managed NTLM/SPNEGO on Apple platforms by default #89267

Merged
merged 1 commit into from
Aug 15, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,10 @@ namespace System.Net
{
internal partial class NegotiateAuthenticationPal
{
private static bool UseManagedNtlm { get; } = AppContext.TryGetSwitch("System.Net.Security.UseManagedNtlm", out bool useManagedNtlm) && useManagedNtlm;
private static bool UseManagedNtlm { get; } =
AppContext.TryGetSwitch("System.Net.Security.UseManagedNtlm", out bool useManagedNtlm) ?
useManagedNtlm :
OperatingSystem.IsMacOS() || OperatingSystem.IsIOS() || OperatingSystem.IsMacCatalyst();

public static NegotiateAuthenticationPal Create(NegotiateAuthenticationClientOptions clientOptions)
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
using System;
using System.Buffers;
using System.Buffers.Binary;
using System.Collections.Generic;
using System.IO;
using System.Net.Security;
using System.Net.Test.Common;
Expand Down Expand Up @@ -148,15 +149,23 @@ public void NtlmProtocolExampleTest()
Assert.False(fakeNtlmServer.IsMICPresent);
}

[ConditionalFact(nameof(IsNtlmAvailable))]
public void NtlmCorrectExchangeTest()
public static IEnumerable<object[]> TestCredentials()
{
using FakeNtlmServer fakeNtlmServer = new FakeNtlmServer(s_testCredentialRight);
yield return new object[] { new NetworkCredential("rightusername", "rightpassword") };
yield return new object[] { new NetworkCredential("rightusername", "rightpassword", "rightdomain") };
yield return new object[] { new NetworkCredential("[email protected]", "rightpassword") };
}

[ConditionalTheory(nameof(IsNtlmAvailable))]
[MemberData(nameof(TestCredentials))]
public void NtlmCorrectExchangeTest(NetworkCredential credential)
{
using FakeNtlmServer fakeNtlmServer = new FakeNtlmServer(credential);
NegotiateAuthentication ntAuth = new NegotiateAuthentication(
new NegotiateAuthenticationClientOptions
{
Package = "NTLM",
Credential = s_testCredentialRight,
Credential = credential,
TargetName = "HTTP/foo",
RequiredProtectionLevel = ProtectionLevel.Sign
});
Expand Down Expand Up @@ -191,7 +200,6 @@ public void NtlmIncorrectExchangeTest()
}

[ConditionalFact(nameof(IsNtlmAvailable))]
[ActiveIssue("https://github.com/dotnet/runtime/issues/65678", TestPlatforms.OSX | TestPlatforms.iOS | TestPlatforms.MacCatalyst)]
public void NtlmSignatureTest()
{
using FakeNtlmServer fakeNtlmServer = new FakeNtlmServer(s_testCredentialRight);
Expand Down
Loading