Skip to content

Commit 5610fa9

Browse files
committed
Reset negotiateAuth if SNI doesn't work
1 parent c3857b1 commit 5610fa9

File tree

1 file changed

+8
-0
lines changed

1 file changed

+8
-0
lines changed

src/Microsoft.Data.SqlClient/src/Microsoft/Data/SqlClient/SSPI/NegotiateSspiContextProvider.cs

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,12 @@ protected override bool GenerateSspiClientContext(ReadOnlySpan<byte> incomingBlo
1616
{
1717
NegotiateAuthenticationStatusCode statusCode = NegotiateAuthenticationStatusCode.UnknownCredentials;
1818

19+
// If we've already successfully performed the negotiate we only want to do it for the original target
20+
if (_negotiateAuth is { TargetName: { } name } && name != authParams.Resource)
21+
{
22+
return false;
23+
}
24+
1925
_negotiateAuth ??= new(new NegotiateAuthenticationClientOptions { Package = "Negotiate", TargetName = authParams.Resource });
2026
var sendBuff = _negotiateAuth.GetOutgoingBlob(incomingBlob, out statusCode)!;
2127

@@ -29,6 +35,8 @@ protected override bool GenerateSspiClientContext(ReadOnlySpan<byte> incomingBlo
2935
return true;
3036
}
3137

38+
// Reset _negotiateAuth to be generated again for next SPN.
39+
_negotiateAuth = null;
3240
return false;
3341
}
3442
}

0 commit comments

Comments
 (0)