Fix unordered server endpoint validation - #4029
Merged
marcschier merged 1 commit intoJul 20, 2026
Merged
Conversation
marcschier
approved these changes
Jul 19, 2026
Codecov Report❌ Patch coverage is
❌ Your patch check has failed because the patch coverage (67.44%) is below the target coverage (80.00%). You can increase the patch coverage or adjust the target coverage. Additional details and impacted files@@ Coverage Diff @@
## master #4029 +/- ##
==========================================
- Coverage 73.85% 73.54% -0.32%
==========================================
Files 1345 1345
Lines 179988 180056 +68
Branches 31668 31681 +13
==========================================
- Hits 132938 132415 -523
- Misses 36299 36928 +629
+ Partials 10751 10713 -38
🚀 New features to boost your workflow:
|
Collaborator
|
/azp run |
|
Azure Pipelines successfully started running 1 pipeline(s). |
marcschier
pushed a commit
that referenced
this pull request
Aug 18, 2026
…78] (#4269) Backport of 8f40876 from `master` to `master378`. ### Summary Makes `Session.ValidateServerEndpoints()` compare `ServerEndpoints` and `UserIdentityTokens` as unordered sets and adds regression tests verifying `OpenAsync()` no longer rejects legal servers that return the same endpoint data in a different order. ### Problem Per OPC UA Part 4, the client validates the endpoint set returned by `CreateSessionResponse.ServerEndpoints` against the set observed during discovery. The spec describes these as a *set* of endpoint descriptions filtered by transport profile, not an ordered array. Previously the validation compared `m_discoveryServerEndpoints[ii]` against `serverEndpoints[ii]` by index, and `UserIdentityTokens[jj]` by index. A server returning the same legal endpoints/token policies in a different order could be wrongly rejected with `BadSecurityChecksFailed`. ### Changes - Replace index-based `ServerEndpoints` validation with unordered matching on the same endpoint fields already validated by the client. - Compare `UserIdentityTokens` as an unordered multiset. - Extend the client session test scaffolding so discovery endpoints can be supplied explicitly. - Add regression tests for reordered `ServerEndpoints` and reordered `UserIdentityTokens`. ### Notes Adapted to the `master378` API surface (`EndpointDescriptionCollection` / `UserTokenPolicyCollection` / `StringCollection` / `byte[]` server nonce) and the `Libraries/`/`Tests/` layout. Client tests build and the new tests pass. Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>
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.
Summary
This PR makes
Session.ValidateServerEndpoints()compareServerEndpointsandUserIdentityTokensas unordered sets and adds regression tests that verifyOpenAsync()no longer rejects legal servers that return the same endpoint data in a different order.Problem
According to OPC UA Part 4, the client validates the endpoint set returned by
CreateSessionResponse.ServerEndpointsagainst the endpoint set observed during discovery. The specification describes these values as a set of endpoint descriptions filtered by the relevant transport profile, not as an ordered array that must preserve the exact discovery-time enumeration order.Previously,
Session.ValidateServerEndpoints()first checked the endpoint count and then comparedm_discoveryServerEndpoints[ii]againstserverEndpoints[ii]by index. It also comparedUserIdentityTokens[jj]by index within each endpoint. As a result, a server that returned the same legal endpoints in a different order, or returned the same token policies in a different order within an endpoint, could be rejected withBadSecurityChecksFailedeven though the endpoint data itself had not changed.Changes
ServerEndpointsvalidation with unordered matching based on the same endpoint fields already validated by the client.UserIdentityTokensas an unordered multiset instead of requiring the server to preserve the original token enumeration order.OpenAsync()accepts reorderedServerEndpointsand reorderedUserIdentityTokens.