Throw PNSE for Extended Protection on unsupported platforms#131144
Merged
Conversation
|
Azure Pipelines: Successfully started running 4 pipeline(s). 12 pipeline(s) were filtered out due to trigger conditions. There may be pipelines that require an authorized user to comment /azp run to run. |
Contributor
|
Tagging subscribers to this area: @dotnet/ncl, @bartonjs, @vcsjones |
ManickaP
approved these changes
Jul 21, 2026
Contributor
There was a problem hiding this comment.
Pull request overview
This PR changes System.Net.Security’s NegotiateAuthentication server-side constructor to proactively throw PlatformNotSupportedException when Extended Protection is explicitly enforced (PolicyEnforcement.Always) on platforms that don’t support Extended Protection, and adds a unit test covering non-Windows behavior.
Changes:
- Add a server-side constructor guard that throws
PlatformNotSupportedExceptionwhenPolicyEnforcement.Alwaysis requested butExtendedProtectionPolicy.OSSupportsExtendedProtectionis false. - Add a new localized resource string for the exception message.
- Add a non-Windows unit test asserting the constructor throws when Extended Protection is enforced.
Reviewed changes
Copilot reviewed 3 out of 3 changed files in this pull request and generated 2 comments.
| File | Description |
|---|---|
| src/libraries/System.Net.Security/src/System/Net/Security/NegotiateAuthentication.cs | Adds the PolicyEnforcement.Always + OSSupportsExtendedProtection PNSE guard in the server constructor. |
| src/libraries/System.Net.Security/src/Resources/Strings.resx | Adds a new SR string used by the PNSE thrown from NegotiateAuthentication. |
| src/libraries/System.Net.Security/tests/UnitTests/NegotiateAuthenticationTests.cs | Adds a non-Windows test verifying PNSE when Extended Protection is enforced. |
rzikm
enabled auto-merge (squash)
July 21, 2026 12:40
liveans
approved these changes
Jul 21, 2026
Member
Author
|
/ba-g test failure is unrelated |
Member
Author
|
/backport to release/11.0-preview7 |
Contributor
|
Started backporting to |
2 tasks
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Implement a check that throws a
PlatformNotSupportedExceptionwhen Extended Protection is enforced on platforms that do not support it. Add a corresponding error message for clarity. Include a test to verify this behavior on non-Windows platforms.