Skip to content

Merge and addapt Secure channel enhancements to new master code#3567

Open
mrsuciu wants to merge 53 commits intoOPCFoundation:masterfrom
mrsuciu:secure-channel-enhancements-2025-11-merge5
Open

Merge and addapt Secure channel enhancements to new master code#3567
mrsuciu wants to merge 53 commits intoOPCFoundation:masterfrom
mrsuciu:secure-channel-enhancements-2025-11-merge5

Conversation

@mrsuciu
Copy link
Contributor

@mrsuciu mrsuciu commented Feb 19, 2026

Proposed changes

Merge and addapt Secure channel enhancements to new master code

Related Issues

  • Fixes #

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 and others added 30 commits November 19, 2025 16:23
Update version from 1.5.378-preview to 1.5.378
…, and correcting ECC_brainpoolP384r1/Basic128Rsa15 IV, signature, padding, and nonce parameters.
…n encrypting user tokens; this prevents null payloads from causing BadIdentityTokenInvalid.
…estores ServerNonce and reconstructs ECC ephemeral key Nonce from bytes and policy
…ies() for all six ECC certificate types (nistP256, nistP384, brainpoolP256r1, brainpoolP384r1, curve25519, curve448) to SecurityConfiguration. Added Sign and SignAndEncrypt endpoints for the four ECC AesGcm/ChaChaPoly policy pairs (nistP256, nistP384, brainpoolP256r1, brainpoolP384r1) to ServerFixture.
@codecov
Copy link

codecov bot commented Feb 19, 2026

Codecov Report

❌ Patch coverage is 79.91218% with 549 lines in your changes missing coverage. Please review.
✅ Project coverage is 66.35%. Comparing base (d25caff) to head (a2b008e).
⚠️ Report is 129 commits behind head on master.

Files with missing lines Patch % Lines
...k/Opc.Ua.Core/Security/Certificates/CryptoUtils.cs 79.86% 43 Missing and 48 partials ⚠️
...Opc.Ua.Core/Security/Constants/SecurityPolicies.cs 64.10% 62 Missing and 22 partials ⚠️
Libraries/Opc.Ua.Client/Session/Session.cs 73.57% 42 Missing and 23 partials ⚠️
...c.Ua.Core/Security/Certificates/EncryptedSecret.cs 75.09% 42 Missing and 21 partials ⚠️
Libraries/Opc.Ua.Server/Server/StandardServer.cs 34.04% 62 Missing ⚠️
Stack/Opc.Ua.Core/Stack/Tcp/TcpServerChannel.cs 34.56% 51 Missing and 2 partials ⚠️
Stack/Opc.Ua.Core/Security/Certificates/Nonce.cs 80.44% 24 Missing and 11 partials ⚠️
...c.Ua.Core/Security/Constants/SecurityPolicyInfo.cs 96.65% 11 Missing and 13 partials ⚠️
Libraries/Opc.Ua.Server/Session/Session.cs 68.29% 11 Missing and 2 partials ⚠️
...c.Ua.Server/Session/SessionSecurityPolicyHelper.cs 81.13% 7 Missing and 3 partials ⚠️
... and 13 more
Additional details and impacted files
@@             Coverage Diff             @@
##           master    #3567       +/-   ##
===========================================
+ Coverage   51.86%   66.35%   +14.48%     
===========================================
  Files         370      462       +92     
  Lines       78618    99053    +20435     
  Branches    13650    16524     +2874     
===========================================
+ Hits        40779    65724    +24945     
+ Misses      33705    28191     -5514     
- Partials     4134     5138     +1004     

☔ 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.

}
}

ITransportChannel activeChannel = TransportChannel;
Copy link
Contributor

Choose a reason for hiding this comment

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

we should add an enhancement Issue to get all this SecurityPolicy Specific stuff out of the main session class into a helper IMO. all signing/ encrypting / additional headers should be separate. But not required in this PR. Also the User Token handling / selection.

@@ -499,10 +494,19 @@ X509Certificate2Collection clientCertificateChain
// sign the client nonce (if provided).
if (parsedClientCertificate != null && clientNonce != null)
Copy link
Contributor

Choose a reason for hiding this comment

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

all this logic should inclduing the Additional header not be in the StandardServer class, instead we should do it in a helper living in the Session folder of the Server.

// create server nonce.
var serverNonceObject = Nonce.CreateNonce(
context.ChannelContext.EndpointDescription.SecurityPolicyUri);
var serverNonceObject = Nonce.CreateNonce(0);
Copy link
Contributor

Choose a reason for hiding this comment

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

isnt the nonce length dependent on the security policy?

}

/// <summary>
/// Verifies a ECDsa signature.
Copy link
Contributor

Choose a reason for hiding this comment

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

Suggested change
/// Verifies a ECDsa signature.
/// Verifies a signature.


if (oscRequestSignature != null && SecurityPolicy.SecureChannelEnhancements)
{
// copy osc request signature if provided before verifying.
Copy link
Contributor

Choose a reason for hiding this comment

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

osc is OpenSecureChannel?

.AddEccSignPolicies()
.AddEccSignAndEncryptPolicies();
.AddEccSignAndEncryptPolicies()
.AddPolicy(MessageSecurityMode.Sign, SecurityPolicies.ECC_nistP256_AesGcm)
Copy link
Contributor

Choose a reason for hiding this comment

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

we should do a new helper

@@ -130,8 +130,28 @@ public async Task LoadConfigurationAsync(string pkiRoot = null)
.AddPolicy(MessageSecurityMode.SignAndEncrypt, SecurityPolicies.Basic256)
.AddSignPolicies()
.AddSignAndEncryptPolicies()
.AddPolicy(MessageSecurityMode.Sign, SecurityPolicies.RSA_DH_AesGcm)
Copy link
Contributor

Choose a reason for hiding this comment

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

we should do a new helper

@mrsuciu mrsuciu marked this pull request as ready for review February 19, 2026 15:32
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.

4 participants