Skip to content

Allow application certificate lookup to use entries configured with abstract ApplicationCertificateType only as fallback candidates.#3752

Draft
mrsuciu wants to merge 2 commits into
OPCFoundation:masterfrom
mrsuciu:master-fallbackApplicationCertificateType
Draft

Allow application certificate lookup to use entries configured with abstract ApplicationCertificateType only as fallback candidates.#3752
mrsuciu wants to merge 2 commits into
OPCFoundation:masterfrom
mrsuciu:master-fallbackApplicationCertificateType

Conversation

@mrsuciu
Copy link
Copy Markdown
Contributor

@mrsuciu mrsuciu commented May 11, 2026

Proposed changes

Tries to rectify inconsistent behavior: SecurityConfiguration::BuilldSupportedSecurityPolicies() advertises RSA policies if ApplicationCertificateType is set as CertificateType, while ApplicationCertificateType is not used when finding actual certificates.

Use CertificateIdentifier::SetCertificate(certificate) to recalculate the CertificateType whenever the identifier receives a X509Certificate2.

Removed stale if case if (certType == ObjectTypeIds.ApplicationCertificateType) from SecurityConfiguration::FindApplicationCertificateAsync, since CertificateIdentifier.MapSecurityPolicyToCertificateTypes(securityPolicy) never returned 'ApplicationCertificateType' and it was confusing and misleading because it suggested support for abstract ApplicationCertificateType, but normal policy lookup did not actually go through it.

Allow application certificate lookup to use entries configured with abstract ApplicationCertificateType as fallback candidates.
The fallback loads the candidate certificate first, then validates it against the concrete type required by the selected security policy.

'ApplicationCertificateType' is not a concrete certificate profile and should not be prefered in configuration, even if older configurations may use it. Previously, such entries could be missed during certificate lookup because the selected security policy maps to a concrete type.

Related Issues

Types of changes

What types of changes does your code introduce?
Put an x in the boxes that apply. You can also fill these out after creating the PR.

  • Bugfix (non-breaking change which fixes an issue)
  • Enhancement (non-breaking change which adds functionality)
  • Test enhancement (non-breaking change to increase test coverage)
  • Breaking change (fix or feature that would cause existing functionality to not work as expected, requires version increase of Nuget packages)
  • Documentation Update (if none of the other choices apply)

Checklist

Put an x in the boxes that apply. You can also fill these out after creating the PR. If you're unsure about any of them, don't hesitate to ask. We're here to help! This is simply a reminder of what we are going to look for before merging your code.

  • I have read the CONTRIBUTING doc.
  • I have signed the CLA.
  • I ran tests locally with my changes, all passed.
  • I fixed all failing tests in the CI pipelines.
  • I fixed all introduced issues with CodeQL and LGTM.
  • I have added tests that prove my fix is effective or that my feature works and increased code coverage.
  • I have added necessary documentation (if appropriate).
  • Any dependent changes have been merged and published in downstream modules.

Further comments

If this is a relatively large or complex change, kick off the discussion by explaining why you chose the solution you did and what alternatives you considered, etc...

mrsuciu added 2 commits May 8, 2026 20:02
Normalize loaded certificates to their concrete OPC UA certificate type and
allow application certificate lookup to use entries configured with abstract
ApplicationCertificateType as fallback candidates. The fallback now loads the
candidate certificate first, then validates it against the concrete type
required by the selected security policy.

Also guard IsSupportedCertificateType against null certificate types and add
regression coverage for abstract ApplicationCertificateType lookup and
normalization.
@codecov
Copy link
Copy Markdown

codecov Bot commented May 11, 2026

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 72.09%. Comparing base (bd4543e) to head (da82353).
⚠️ Report is 2 commits behind head on master.

Additional details and impacted files
@@            Coverage Diff             @@
##           master    #3752      +/-   ##
==========================================
- Coverage   72.11%   72.09%   -0.02%     
==========================================
  Files         572      572              
  Lines      120749   120793      +44     
  Branches    20173    20178       +5     
==========================================
+ Hits        87073    87089      +16     
- Misses      27836    27860      +24     
- Partials     5840     5844       +4     

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

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

CertificateType = GetCertificateType(m_certificate);
}
}
set => SetCertificate(value);
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.

maybe use c# 14 field keyword and set the Certificate property instead of introducing SetCertificate meth

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

Certificate Identifier now is just what it says, an id that is used to look up the certificate at any point in time from the registry. It does not cache the certificate anymore and it is not a store. Therefore this code is not needed anymore. The fix to select a valid certificate type needs to be applied when the Identifier is converted to a certificate.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

TBH the code was prepared on master378 and I moved it on master ... thanks for the highlight

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[Client] ApplicationCertificate CertType weired behavior ?

3 participants