Skip to content

Use application certificate validation during WSS discovery - #4136

Merged
marcschier merged 1 commit into
OPCFoundation:masterfrom
jpfr:jpfr/fix-wss-client-discovery
Aug 4, 2026
Merged

Use application certificate validation during WSS discovery#4136
marcschier merged 1 commit into
OPCFoundation:masterfrom
jpfr:jpfr/fix-wss-client-discovery

Conversation

@jpfr

@jpfr jpfr commented Jul 30, 2026

Copy link
Copy Markdown
Contributor

ConfiguredEndpoint refreshed endpoint descriptions with a DiscoveryClient created only from EndpointConfiguration. That path did not receive the application certificate manager, so WSS discovery could not validate a server certificate trusted by the application before opening a session.

Add an ApplicationConfiguration-aware endpoint refresh overload and use it from the default and channel-manager session paths. Preserve the existing overloads for compatibility.

The application-aware DiscoveryClient now supplies the configured certificate validation for secure discovery transports while TCP and legacy callers retain their existing behavior.

Specification:
https://reference.opcfoundation.org/Core/Part6/v105/docs/7.5.3

Tests: UpdateFromServerWithNullApplicationConfigurationThrowsArgumentNullException (1 passed, net10.0)

Tests: UpdateBeforeConnectUsesApplicationCertificateValidationAsync (1 passed, net10.0)

Description

Describe the changes here to communicate to the maintainers why they should accept this pull request. By default - this will become the Commit message after merging and thus define history.

Related Issues

Reference all GitHub issues this PR addresses. If there is no issue yet, open one and link it here.

If this is a relatively large or complex change, a design must have been discussed in the related tracking issue and signed off (which becomes the Architectural Decision Record (ADR)).

  • Fixes #github-issue-number, ...

Checklist

Put an x in the boxes that apply. You can complete these step by step after opening the PR.

  • I have signed the CLA and read the CONTRIBUTING doc.
  • I have added tests that prove my fix is effective or that my feature works and increased code coverage.
  • I have added all necessary documentation.
  • I have verified that my changes do not introduce (new) build or analyzer warnings.
  • I ran all tests locally using the UA.slnx solution against at least .net framework and .net 10, and all passed.
  • I fixed all failing and flaky tests in the CI pipelines and all CodeQL warnings.
  • I have addressed all PR feedback received.

ConfiguredEndpoint refreshed endpoint descriptions with a DiscoveryClient
created only from EndpointConfiguration. That path did not receive the
application certificate manager, so WSS discovery could not validate a
server certificate trusted by the application before opening a session.

Add an ApplicationConfiguration-aware endpoint refresh overload and use it
from the default and channel-manager session paths. Preserve the existing
overloads for compatibility.

The application-aware DiscoveryClient now supplies the configured
certificate validation for secure discovery transports while TCP and legacy
callers retain their existing behavior.

Specification:
https://reference.opcfoundation.org/Core/Part6/v105/docs/7.5.3

Tests: UpdateFromServerWithNullApplicationConfigurationThrowsArgumentNullException
(1 passed, net10.0)

Tests: UpdateBeforeConnectUsesApplicationCertificateValidationAsync
(1 passed, net10.0)
Copilot AI review requested due to automatic review settings July 30, 2026 19:02

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Note

Copilot couldn't run its full agentic review because it didn't start before the timeout. Make sure your repository has a runner available, or add a copilot-code-review.yml file specifying one with the runs-on attribute. See the docs for more details.

This PR ensures WSS discovery uses the application’s configured certificate validation by refreshing endpoint descriptions via an ApplicationConfiguration-aware discovery client, while retaining existing overloads for backward compatibility.

Changes:

  • Added an ApplicationConfiguration-aware ConfiguredEndpoint.UpdateFromServerAsync overload and refactored logic into a shared core method.
  • Updated session/channel-manager flows to use the new overload when updateBeforeConnect is enabled.
  • Added/updated tests to cover the null-configuration guard and validate WSS update-before-connect behavior.

Reviewed changes

Copilot reviewed 6 out of 6 changed files in this pull request and generated 2 comments.

Show a summary per file
File Description
tests/Opc.Ua.Sessions.Tests/WssTransportIntegrationTests.cs Adds an integration test to exercise update-before-connect over WSS with application certificate validation in place.
tests/Opc.Ua.Core.Tests/Stack/Client/ConfiguredEndpointTests.cs Adds a unit test verifying the new overload throws ArgumentNullException when ApplicationConfiguration is null.
src/Opc.Ua.Core/Stack/Configuration/ConfiguredEndpoints.cs Introduces the application-aware overload and routes discovery client creation through ApplicationConfiguration when provided.
src/Opc.Ua.Client/Session/Session.ChannelManager.cs Switches update-before-connect to call the application-aware endpoint refresh overload.
src/Opc.Ua.Client/Session/DefaultSessionFactory.cs Switches discovery-based endpoint refresh to use application configuration for certificate validation.
src/Opc.Ua.Client/Session/ChannelManagerSessionFactory.cs Switches endpoint refresh during preparation to pass ApplicationConfiguration.

Comment thread tests/Opc.Ua.Core.Tests/Stack/Client/ConfiguredEndpointTests.cs
Comment thread src/Opc.Ua.Core/Stack/Configuration/ConfiguredEndpoints.cs
@marcschier

Copy link
Copy Markdown
Collaborator

/azp run

@azure-pipelines

Copy link
Copy Markdown
Azure Pipelines successfully started running 1 pipeline(s).

@marcschier

Copy link
Copy Markdown
Collaborator

@jpfr please resolve the copilot issues, then this is ready to go IMO. Thanks for the help!

@marcschier marcschier added the ready Ready to merge once CI Passes label Jul 31, 2026
@codecov

codecov Bot commented Jul 31, 2026

Copy link
Copy Markdown

Codecov Report

❌ Patch coverage is 84.37500% with 5 lines in your changes missing coverage. Please review.
✅ Project coverage is 79.92%. Comparing base (8a10139) to head (b52127e).
⚠️ Report is 4 commits behind head on master.

Files with missing lines Patch % Lines
....Ua.Client/Session/ChannelManagerSessionFactory.cs 0.00% 3 Missing ⚠️
...Ua.Core/Stack/Configuration/ConfiguredEndpoints.cs 92.00% 0 Missing and 2 partials ⚠️
Additional details and impacted files

Impacted file tree graph

@@            Coverage Diff             @@
##           master    #4136      +/-   ##
==========================================
- Coverage   80.23%   79.92%   -0.31%     
==========================================
  Files        1515     1515              
  Lines      209980   210008      +28     
  Branches    36213    36215       +2     
==========================================
- Hits       168479   167852     -627     
- Misses      28867    29561     +694     
+ Partials    12634    12595      -39     
Files with missing lines Coverage Δ
src/Opc.Ua.Client/Session/DefaultSessionFactory.cs 87.30% <100.00%> (+0.13%) ⬆️
...rc/Opc.Ua.Client/Session/Session.ChannelManager.cs 79.23% <100.00%> (ø)
...Ua.Core/Stack/Configuration/ConfiguredEndpoints.cs 74.76% <92.00%> (-2.78%) ⬇️
....Ua.Client/Session/ChannelManagerSessionFactory.cs 35.86% <0.00%> (-0.40%) ⬇️

... and 55 files with indirect coverage changes

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

@marcschier
marcschier merged commit 74e272e into OPCFoundation:master Aug 4, 2026
172 of 173 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

ready Ready to merge once CI Passes

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants