Skip to content

Notify certificate manager after GDS certificate revocation - #5070

Merged
marcschier merged 10 commits into
masterfrom
marcschier-gds-certificate-revocation-fix
Nov 13, 2026
Merged

marcschier merged 10 commits into
masterfrom
marcschier-gds-certificate-revocation-fix

Conversation

@marcschier

@marcschier marcschier commented Nov 12, 2026 •

Copy link
Copy Markdown
Collaborator

Description

When the GDS revokes a certificate, it now notifies the server's certificate manager. Before this change, RevokeCertificate wrote the new CRL to the issuer store but raised no CrlUpdated event. As a result, a SecureChannel already open with the revoked certificate stayed usable. In the report, an ApplicationSelfAdmin session could still call UpdateApplication after its certificate was revoked, while new connections already failed with BadSecurityChecksFailed.

After the CRL is written, the shared revocation path calls NotifyTrustListChanged(TrustListIdentifier.Peers, trustChanged: false, crlChanged: true) once. The server's trust-material enforcement then revalidates the open SecureChannels and closes the one that uses the revoked certificate, so the session can no longer be used. The path covers both RevokeCertificate and the revocations done during UnregisterApplication. If the notification fails, the failure is logged and the persisted revocation is kept.

GetGroupForCertificate now takes the certificate type that the caller already knows from the application record, instead of inferring the type from the certificate. This selects the certificate group by the type the certificate was registered for.

Following review, this PR does not sync the CRL into the scoped HTTPS or user-token issuer stores. That can be handled in a separate PR.

New end-to-end test RevokeCertificateSessionTest:

  1. Issues a GDS certificate to a client and opens a self-admin session with it.
  2. Revokes the certificate through the GDS from a separate admin session.
  3. Asserts that the self-admin session can no longer call GetApplication.

The existing ClientTest.RevokeGoodCertificatesAsync also verifies the Peers CrlUpdated notification. No public API or configuration changes are introduced.

CI fixes included in this PR

The PR also fixes CI failures that do not come from the GDS change, so the checks can pass:

  • SDK pin. GitHub-hosted runner images preinstall SDKs newer than the one in global.json, and the global.json roll-forward policy lets the dotnet host select them. When this PR started, global.json pinned 10.0.403 with rollForward: latestMajor, so setup-dotnet picked the preinstalled SDK 11, and its new analyzers failed the build. Master has since moved to 11.0.100 with rollForward: latestFeature (Add net11.0 target, run PR CI on net11.0, fix .NET 11 SDK analyzer findings #5072), which still lets a newer preinstalled 11.0 feature band win. The new composite action .github/actions/setup-repository-dotnet installs the exact global.json SDK, plus any extra SDKs a job needs (such as the 10.0.x runtime for net10.0 jobs), into a job-private directory under RUNNER_TEMP. The job fails unless dotnet resolves that exact SDK. Every workflow except release.yml uses the action. release.yml is unchanged because it checks out a candidate commit that can predate the action, and it only pushes packages that were already built.
  • Aspire bundle. Jobs that build the Aspire AppHost now install the Aspire CLI bundle first (.github/scripts/install-aspire-bundle.ps1). Before, the AppHost build ran aspire setup itself under a two-minute timeout and intermittently failed with ASPIRE009. The bundle is installed for net10.0 and net11.0 legs, because the AppHost imports the Aspire SDK for both.
  • WoT unload race. ProgrammaticUnloadAppliesPolicyWithoutReactivatingItsResolutionInput(Force) failed intermittently with "Serving references changed during preparation." The registry reconcile queue writes registry node references while a lifecycle publication is being prepared, so the server rejects the reservation before the durable decision. Activation units already retried this conflict. Unload and retire-only publications, which have an empty activation plan, did not. Both paths in WotMaterializationCoordinator now share one retry helper with the existing three-attempt budget and a short backoff. Conflicts after the decision and unrelated failures are still not retried. The new test UnloadPublicationRetriesPredecisionReferenceConflictsWithinThePublicationBudget injects the conflict at the unload commit. It failed for 1 and 2 conflicts before the fix and passes after it.
  • Redundancy connection-state flake. FailoverAsyncSwitchesToExplicitTargetAsync(True) failed intermittently with "Expected: Failover But was: Connected". ConnectionStateMachine releases the ConnectAsync waiters before it dispatches the Connecting → Connected notification. A handler subscribed right after ConnectAsync returns can therefore still receive that initial transition. This test and two reverse-connect redundancy tests that subscribe the same way now ignore transitions that start in Connecting, through a shared RecordStatesAfterConnect helper. A 1 s delay injected before the dispatch made all three tests fail. With the change, they pass with and without the delay.
  • origin/master, including the net11.0 target and SDK 11 move (Add net11.0 target, run PR CI on net11.0, fix .NET 11 SDK analyzer findings #5072), was merged into the branch. The workflow conflicts were resolved by keeping the shared action and passing master's extra 10.0.x installs through its dotnet-version input.

Follow-ups, not part of this PR:

  • WotRegistryNodeManager.SafeReconcileAsync logs and drops reconcile failures. A partially created version node can then stay attached without its registry entry.
  • .azurepipelines/onefuzz.yml still uses UseDotNet@2 with useGlobalJson.
  • ConnectionStateMachine signals that a connect, failover or reconnect has settled before it dispatches the matching ConnectionStateChanged notification. A subscriber attached after the awaited call returns can receive a stale transition. Changing that order also affects settled resets from concurrent requests, so it needs a separate change.

Validation

TEMP and TMP were set to D:\temp.

Command Result
dotnet test tests\Opc.Ua.Gds.Tests\Opc.Ua.Gds.Tests.csproj -f net10.0 --filter "FullyQualifiedName~RevokeCertificateSessionTest|FullyQualifiedName~Opc.Ua.Gds.Tests.ClientTest|FullyQualifiedName~CustomCertificateGroupIntegrationTest" Passed: 111, Failed: 0, Skipped: 0.
Same command with -f net48 Passed: 109, Failed: 0, Skipped: 2.
dotnet test tests\Opc.Ua.Tools.Tests\Opc.Ua.Tools.Tests.csproj -f net10.0 -p:CustomTestTarget=net10.0 --filter "FullyQualifiedName~TestMatrixScriptTests|FullyQualifiedName~CiPathRelevanceTests" Passed: 45, Failed: 0, Skipped: 0.
dotnet test tests\Opc.Ua.WotCon.Tests\Opc.Ua.WotCon.Tests.csproj -f net10.0 -p:CustomTestTarget=net10.0 --filter "FullyQualifiedName~WotAtomicPublicationNativeTests" Passed: 302, Failed: 0, Skipped: 0.
Same WotCon command filtered to UnloadPublicationRetries, with the unload path temporarily reverted Failed: 3 of 3, with "Serving references changed during preparation." for 1 and 2 conflicts (red check).
dotnet test tests\Opc.Ua.Client.Tests\Opc.Ua.Client.Tests.csproj -f net10.0 -p:CustomTestTarget=net10.0 --filter "FullyQualifiedName~ManagedSessionServerRedundancyTests" with a temporary 1 s delay before the Connecting → Connected dispatch, before the test change FailoverAsyncSwitchesToExplicitTargetAsync (both cases), ReverseConnectServiceLevelDropFailsOverOverMemberConnectionAsync and ReverseConnectMemberWithoutConnectionIsNeverSelectedAsync failed with the CI symptom (red check).
Same command after the test change, with the delay Passed: 25, Failed: 0, Skipped: 0.
Same command after the test change, without the delay Passed: 25, Failed: 0, Skipped: 0.
After merging #5072, with SDK 11.0.100: dotnet test tests\Opc.Ua.Tools.Tests\Opc.Ua.Tools.Tests.csproj -f net10.0 -p:CustomTestTarget=net10.0 --filter "FullyQualifiedName~TestMatrixScriptTests" Passed: 23, Failed: 0, Skipped: 0.
After merging #5072: dotnet build of Opc.Ua.Gds.Tests, Opc.Ua.WotCon.Tests and Opc.Ua.Client.Tests with -f net11.0 -p:CustomTestTarget=net11.0 Succeeded with 0 warnings and 0 errors.
After merging #5072: dotnet test tests\Opc.Ua.Gds.Tests\Opc.Ua.Gds.Tests.csproj -f net11.0 -p:CustomTestTarget=net11.0 --filter "FullyQualifiedName~RevokeCertificateSessionTest" Passed: 1, Failed: 0, Skipped: 0.
Negative control: I ran dotnet test tests\Opc.Ua.Gds.Tests\Opc.Ua.Gds.Tests.csproj -f net10.0 --filter "FullyQualifiedName~RevokeCertificateSessionTest" -p:TreatWarningsAsErrors=false -p:RunAnalyzers=false with the NotifyTrustListChanged call temporarily disabled. RevokeCertificateSessionTest failed after its 30 s deadline with "The session using the revoked certificate can still be used." With the call restored, the test passes in about 1 s. Coverage delta was not measured.

The full UA.slnx suite was not run locally. Earlier local net48 solution runs were blocked by environment-specific path failures in unrelated fixtures (AMB, SourceGeneration, OpenUsd). CI covers the full suite.

Related Issues

  • Addresses the privately supplied GDS certificate-revocation report; no public tracking issue is linked.

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.
  • If this PR changes C# source files, I ran all tests locally using the UA.slnx solution against at least .NET Framework and .NET 10, and all passed. PRs changing only non-C# files do not require these .NET test runs.
  • I fixed all failing and flaky tests in the CI pipelines and all CodeQL warnings.
  • I have addressed all PR feedback received.

RevokeCertificate and UnregisterApplication wrote the CRL to the stores but never
raised CrlUpdated, so the trust material enforcement pump did not revalidate
already open channels and sessions using the revoked certificate.
Copilot AI balanced review requested due to automatic review settings November 12, 2026 11:24

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.

🟡 Changes recommended

Revocation notifications can leave revoked certificates accepted when HTTPS or user validation uses separate stores because the updated CRL is not persisted to those stores.

1 open issue
What changed in this PR

This PR connects GDS certificate revocation to the certificate manager’s existing trust-material enforcement so persisted revocations trigger revalidation.

Changes:

  • Notifies the peer trust list and applicable HTTPS or user scope after successful revocation, including during application unregistration.
  • Logs notification failures without undoing persisted revocations.
  • Extends the client regression test to verify peer-CRL notifications; end-to-end session closure remains unverified.
File Description
tests/​Opc.Ua.Gds.Tests/​ClientTest.cs Verifies peer-CRL notifications after successful revocations.
src/​Opc.Ua.Gds.Server/​ApplicationsNodeManager.cs Adds scope-aware revocation notifications and failure logging.

Review effort: Balanced

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.

🟡 Changes recommended

ClientTest covers only Default-group peer notifications, leaving HTTPS and user-token scope notifications—including the Users notification that triggers active X.509 session revalidation—without regression coverage.

1 open issue
1 resolved since last review

Review effort: Balanced

@github-actions

github-actions Bot commented Nov 12, 2026 •

Copy link
Copy Markdown

Code coverage

✅ Coverage gate passed.

Check Result Threshold
✅ Project line rate 89.19% (493692/553512 lines) >= 70.00%
✅ Project branch rate 79.72% >= 60.00%
✅ Patch coverage 91.18% (31/34 changed lines) >= 60.00% (<= 100 changed lines, advisory)
ℹ️ Baseline delta (advisory) +15.59 pp 73.60% recorded
Uncovered changed lines
  • src/Opc.Ua.Gds.Server/ApplicationsNodeManager.cs: 851, 853, 854

Coverage is above the recorded baseline - consider ratcheting coverage-thresholds.json.

Thresholds live in coverage-thresholds.json. Whole report before exclusions: line 88.52%, branch 79.06%.

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.

🟡 Changes recommended

Critical revocation-handling defects can suppress peer revalidation after partial updates, bypass configured store providers, and leave historical issuers’ CRLs stale in HTTPS/user stores.

3 open issues
1 resolved since last review

Review effort: Balanced

@romanett romanett 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.

Please add an integration test where a client revokes its own certificate to ensure the session is closed (if this is blocked by gds, use a second client / session)

@marcschier

Copy link
Copy Markdown
Collaborator Author

No threshold change is needed for this report: it confirms the coverage gate passed and labels ratcheting as advisory. I left the global coverage threshold unchanged; the focused regressions added for this review cover the scoped-store and notification behavior.

@romanett

Copy link
Copy Markdown
Contributor

Review note: this can be much smaller. To end sessions whose client certificate was revoked, the only missing piece is the CrlUpdated notification after the GDS writes the new CRL. CertificateGroup.RevokeCertificateAsync already copies the CRL into TrustedIssuerCertificates, and the trust-material handler in ConfigurationNodeManager already revalidates and closes channels and sessions on CrlUpdated.

Suggestions

  1. Drop UpdateScopedIssuerCertificatesStoreAsync (about 75 lines), or move it to a separate PR.

    • It's a near-copy of CertificateGroup.UpdateAuthorityCertInCertificateStoreAsync.
    • It also runs from InitializeCertificateGroupAsync, so every GDS would now copy the HTTPS and user-token CA into HttpsIssuerCertificates and UserIssuerCertificates at startup. That behaviour change isn't in the PR description.
    • If we want it, it should reuse the existing method rather than add a second copy.
    • Dropping it also removes OpenCertificateStore, IsSameStore, ResolveStoreType, RevocationScopeStoreUpdateFailed, the new test config stores and most of the new CustomCertificateGroupIntegrationTest code.
  2. The two error paths contradict each other. A failed notification is logged and ignored, but a failed copy to the scoped issuer store throws BadUnexpectedError after the revocation is already saved. The caller then sees a failure for a revocation that took effect.

  3. One mapping is written twice in different ways. GetScopedIssuerCertificatesStore matches the config id strings ("DefaultHttpsGroup", "DefaultUserTokenGroup"), while GetScopedTrustListIdentifier matches m_defaultHttpsGroupId and m_defaultUserTokenGroupId. Keep only one.

  4. NotifyRevocationListChanged takes the whole certificate group only to log its id. One call inside a try/catch is enough:

    if (crl != null)
    {
        revoked = true;
        try
        {
            m_configuration.CertificateManager?.NotifyTrustListChanged(
                TrustListIdentifier.Peers, trustChanged: false, crlChanged: true);
        }
        catch (Exception ex)
        {
            m_logger.RevocationNotificationFailed(ex, certificateGroup.Id);
        }
    }
  5. Keep the certificateType parameter on GetGroupForCertificate. It's a real fix: the old lookup guessed the type from the certificate (the application RSA type), which never matches the HTTPS or user-token groups, so revoking those certificates found no group. Please mention it in the PR description.

Tests: the current tests check that the notification and the store copies happen, but none shows that an open session is actually closed after RevokeCertificate. A test that opens a session, revokes its certificate through the GDS and asserts that the session is closed would prove the fix more directly. It could replace most of the store-copy tests.

With items 1–5, the product change would be about 40 lines instead of about 240.

Per review: drop the scoped HTTPS/Users store CRL sync, notify the
certificate manager once for the Peers scope when the CRL is updated
and log notification failures. Keep passing the certificate type to
GetGroupForCertificate so the group is selected by the type the
certificate was issued for.

Add an end-to-end test that opens a self-admin session with a GDS
issued certificate, revokes the certificate through the GDS and
asserts that the session can no longer be used.
@marcschier

Copy link
Copy Markdown
Collaborator Author

@romanett thanks, all applied in 40c00ec. The product change is now +28/−4 lines in ApplicationsNodeManager.cs.

  1. Scoped store sync dropped. UpdateScopedIssuerCertificatesStoreAsync, the store helpers, RevocationScopeStoreUpdateFailed, the extra test config stores and the store-copy tests in CustomCertificateGroupIntegrationTest are removed. Startup no longer copies the HTTPS or user-token CA. If we want that sync, it can come in a separate PR that reuses UpdateAuthorityCertInCertificateStoreAsync.
  2. Contradicting error paths: gone together with the store copy. Once the CRL is saved, the only remaining failure point is the notification, and that failure is logged without failing the call.
  3. Duplicate group mapping: removed. Neither GetScopedIssuerCertificatesStore nor GetScopedTrustListIdentifier exists any more.
  4. Single notification: inside if (crl != null) there is now one guarded NotifyTrustListChanged(TrustListIdentifier.Peers, trustChanged: false, crlChanged: true). A failure is logged with RevocationNotificationFailed(ex, certificateGroup.Id).
  5. certificateType on GetGroupForCertificate: kept. Both callers pass the type from the application record, and the PR description now mentions the fix.

End-to-end test (also for your review 5875202650): RevokeCertificateSessionTest replaces the store-copy tests.

  • It issues a GDS certificate to a client and opens a session with it. The session has ApplicationSelfAdmin rights, and GetApplication succeeds.
  • RevokeCertificate requires CertificateAuthorityAdmin, so the client cannot revoke its own certificate. The test revokes it from a second admin session, which uses the original certificate.
  • The test then asserts that the first session's GetApplication call fails. This is the symptom from the report.

Note: for a revoked application (peer) certificate, the trust-material handler closes the SecureChannel, not the session object. Only Users-scope changes close sessions, see PushConfigurationTrustListEffectHandler.ApplyAsync. The server-side session therefore stays until it times out, but it can no longer be used, because reactivating it would need a new channel with the revoked certificate. The test asserts this outcome rather than the removal of the session from the SessionManager.

With the notification call disabled, the test fails after its 30 s deadline. With the call in place, it passes in about 1 s. The GDS ClientTest, CustomCertificateGroupIntegrationTest and the new test pass on net10.0 (111/111) and net48 (109 passed, 2 skipped).

@romanett romanett 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.

Nice simple fix!

GitHub-hosted runner images now preinstall the .NET 11 SDK. global.json
pins 10.0.403 with rollForward latestMajor, so setup-dotnet resolved the
preinstalled SDK 11 and its new analyzers (CA2027 and others) failed the
build-UA and test jobs.

The new setup-repository-dotnet composite action installs the exact
global.json SDK, plus any extra SDKs a job needs, into a job-private
directory under RUNNER_TEMP, and fails the job unless dotnet resolves that
exact SDK from that directory. Every workflow except release.yml uses it;
the release job checks out a candidate commit that can predate the action
and only pushes packages that were already built.

Jobs that build the Aspire AppHost install the Aspire CLI bundle first, so
the AppHost build does not run 'aspire setup' itself under a two-minute
timeout, which intermittently failed with ASPIRE009.
The WoT registry reconcile queue writes registry node references while a
lifecycle publication is being prepared. The server then rejects the
reservation with "Serving references changed during preparation." before
the durable decision starts, so nothing was published.

Activation units already retried this conflict, but unload and retire-only
publications (an empty activation plan) called RefreshPreparedUnitAsync
directly and surfaced the conflict to the caller. This made
ProgrammaticUnloadAppliesPolicyWithoutReactivatingItsResolutionInput fail
intermittently in CI.

Both paths now share one helper that rebuilds the unit from live serving
state within the existing three-attempt budget, with a short backoff so the
concurrent writer can finish. Conflicts after the decision and unrelated
failures are still propagated without a retry.
@marcschier marcschier added the ready Ready to merge once CI Passes label Nov 12, 2026
FailoverAsyncSwitchesToExplicitTargetAsync failed intermittently in CI with
"Expected: Failover But was: Connected". ConnectionStateMachine releases the
ConnectAsync waiters before it dispatches the Connecting -> Connected
notification, so a handler subscribed right after ConnectAsync returns can
still receive that initial transition. Injecting a delay before the dispatch
reproduced the failure in this test and in two reverse-connect redundancy
tests that subscribe the same way.

The tests now record only transitions that do not start in Connecting, via
a shared RecordStatesAfterConnect helper. All 25 redundancy tests pass with
and without the injected delay.
@codecov

codecov Bot commented Nov 13, 2026 •

Copy link
Copy Markdown

Codecov Report

❌ Patch coverage is 88.23529% with 4 lines in your changes missing coverage. Please review.
✅ Project coverage is 83.59%. Comparing base (70919c3) to head (24449c1).
⚠️ Report is 3 commits behind head on master.

Files with missing lines Patch % Lines
src/Opc.Ua.Gds.Server/ApplicationsNodeManager.cs 63.63% 3 Missing and 1 partial ⚠️
Additional details and impacted files

Impacted file tree graph

@@            Coverage Diff             @@
##           master    #5070      +/-   ##
==========================================
- Coverage   83.59%   83.59%   -0.01%     
==========================================
  Files        3780     3780              
  Lines      553499   553512      +13     
  Branches    94437    94437              
==========================================
- Hits       462723   462691      -32     
- Misses      59563    59599      +36     
- Partials    31213    31222       +9     
Flag Coverage Δ
actions 83.59% <88.23%> (-0.01%) ⬇️

Flags with carried forward coverage won't be shown. Click here to find out more.

Files with missing lines Coverage Δ
...ation/WotMaterializationCoordinator.Publication.cs 87.93% <100.00%> (-0.18%) ⬇️
src/Opc.Ua.Gds.Server/ApplicationsNodeManager.cs 78.12% <63.63%> (-0.14%) ⬇️

... and 39 files with indirect coverage changes

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

Resolve conflicts with the net11.0/SDK 11 move (#5072): keep the
setup-repository-dotnet action in every workflow and pass master's extra
10.0.x runtime installs through its dotnet-version input. Install the
Aspire bundle for net11.0 legs as well, since the AppHost imports the
Aspire SDK for net11.0, and describe the latestFeature roll-forward
policy in the SDK selector and action.
@marcschier
marcschier merged commit 047999f into master Nov 13, 2026
178 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.

3 participants