Skip to content

Commit d188383

Browse files
marcschiermrsuciurandy-armstrong
authored
Secure channel enhancements 2025 11 (Take 3) (#3665)
* merged security changes * Tailor SecurityPolicyUri for format expected in s_securityPolicyUriToInfo * Enhance security policy handling and key computation logic * Merge SecurityEnhancements. * Add support for SessionTransferToken. Removed obsolete SoftwareCertificate code. * Fix NonceLength for None. * Add support for RSA_DH, more fixes from IOP testings. * Finish implementation of SecureChannelEnhancements. * Rename EccUtils.cs to CryptoUtils.cs * Address feedback from reviewers. * Fix CoPilot flagged spelling errors. * Rename EccUtils to CryptoUtils * Update version from 1.5.378-preview to 1.5.378 * Fix unit tests. * Allow SignatureData.Algorithm to be NULL or Empty. * Fix issue with BrainPool_p256r1_ChaChaPoly * Fix RSA_DH_AesGcm * Fix OSC/padding by deriving HMAC keys, tightening symmetric size math, and correcting ECC_brainpoolP384r1/Basic128Rsa15 IV, signature, padding, and nonce parameters. * Policies without asymmetric encryption (ECC) return the plaintext when encrypting user tokens; this prevents null payloads from causing BadIdentityTokenInvalid. * Reserve outer CBC padding for avoiding SymetricEncryptAndSign->AddPadding to overwrite next fields (signature) * Nonce stored as byte array in SessionConfiguration; Sesion snapshot restores ServerNonce and reconstructs ECC ephemeral key Nonce from bytes and policy * Added _AesGcm and _ChaChaPoly variants to BuildSupportedSecurityPolicies() 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. * make ephemeralKeyPolicyUri nullable * GenerateSecret also for NET7 and NET8 * Adjust Basic128Rsa15 policy properties for backword compatibility * Exclude unsuported AEAD policies from .NET Framework client tests * Addapt to new changes (still build fail) * Addapt code to make it compile * Fixed failing build on net48 (by ignoring potential null ref which is not reported on other newer targets) * Preserve the certificate reference in Clone() so copied handlers can still sign * Remove extra code and addapt to existing master configuration settings * Filter *_AesGcm and *_ChaChaPoly security policies based on actual runtime support, so unsupported AEAD policies are not advertised or selected on older frameworks * Expand ECC/RSA policy test coverage and keep Basic128Rsa15 nonce length backward-compatible * Fix ReconnectSessionOnAlternateChannel _AES and _ChaCha policies * Fixed IgnoreIfPolicyNotAdvertised so it now fetches endpoints on-demand (instead of relying on Endpoints being preloaded by earlier tests), which avoids false ignores when running tests directlyy * Merge with commit 5e627f2 from secure-channel-enhancements-2025-11 branch * minor log mesatge formating * Fix ClientLockoutTests * Add ServerFixture policies upfront only if framework and runtime capability supports them * A few cosmetic/config changes as review sugested * Moved the session/security handling from StandardServer into a dedicated helper * use X509IdentityTokenHandler from secure-channel-enhancements-2025-11 * Removed unused Opc.Ua.Types.UnitTests.csproj * test(client): fix Basic128Rsa15 reconnect token-policy coverage Advertise an explicit Basic128Rsa15 user token policy in the test fixture and tighten the reconnect test preconditions for non-advertised policies. * test(client): fix session nonce persistence test helpers Replace the generic reflection helpers in SessionTests with explicit client/server nonce accessors that match the actual field types. Add a short Session comment to explain why client and server nonces currently use different representations. * Merge branch 'master' into secure-channel-enhancements-2025-11-merge5 Merge with latest master and fix conflicts. * Removed unused Opc.Ua.Types.UnitTests.csproj * test(client): fix Basic128Rsa15 reconnect token-policy coverage Advertise an explicit Basic128Rsa15 user token policy in the test fixture and tighten the reconnect test preconditions for non-advertised policies. * test(client): fix session nonce persistence test helpers Replace the generic reflection helpers in SessionTests with explicit client/server nonce accessors that match the actual field types. Add a short Session comment to explain why client and server nonces currently use different representations. * Build fixes * Fix build * update * Minor updates * Fix tests * Add code to check all Endpoints. * Update Design files to 1.05.7 * Run code fixers, add missing docs * Fix build * Revert removal of using * Increase build timeout --------- Co-authored-by: mrsuciu <Mircea-Adrian.Suciu@Softing.com> Co-authored-by: Randy Armstrong <randy@sparhawksoftware.com>
1 parent fc21f2d commit d188383

84 files changed

Lines changed: 100431 additions & 295632 deletions

File tree

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

.azurepipelines/ci.yml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,7 @@ jobs:
2424
arguments: -FileName azure-pipelines.yml -AgentTable ${{ parameters.agents }}
2525
- job: buildall${{ parameters.jobnamesuffix }}
2626
displayName: Build
27+
timeoutInMinutes: 90
2728
dependsOn: buildprep${{ parameters.jobnamesuffix }}
2829
strategy:
2930
matrix: $[dependencies.buildprep${{ parameters.jobnamesuffix }}.outputs['buildmatrix.jobMatrix'] ]

Applications/ConsoleReferenceClient/ClientSamples.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -62,7 +62,7 @@ public interface IUAClient
6262
/// <summary>
6363
/// Sample Session calls based on the reference server node model.
6464
/// </summary>
65-
public class ClientSamples
65+
public partial class ClientSamples
6666
{
6767
private const int kMaxSearchDepth = 128;
6868

Applications/ConsoleReferenceClient/ConsoleReferenceClient.csproj

Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -11,10 +11,7 @@
1111
<PublishAot Condition="$([MSBuild]::IsTargetFrameworkCompatible('$(TargetFramework)', 'net10.0'))">true</PublishAot>
1212
</PropertyGroup>
1313
<ItemGroup>
14-
<Compile
15-
Include="..\ConsoleReferenceServer\ConsoleUtils.cs"
16-
Exclude="bin\**;obj\**;**\*.xproj;packages\**"
17-
/>
14+
<Compile Include="..\ConsoleReferenceServer\ConsoleUtils.cs" Exclude="bin\**;obj\**;**\*.xproj;packages\**" />
1815
</ItemGroup>
1916
<ItemGroup>
2017
<PackageReference Include="Microsoft.Extensions.Logging" />
@@ -36,7 +33,7 @@
3633
</ItemGroup>
3734
<ItemGroup>
3835
<None Update="Quickstarts.ReferenceClient.Config.xml">
39-
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
36+
<CopyToOutputDirectory>Always</CopyToOutputDirectory>
4037
</None>
4138
</ItemGroup>
4239
</Project>

Applications/ConsoleReferenceClient/Program.cs

Lines changed: 19 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -145,6 +145,7 @@ public static Task<int> Main(string[] args)
145145
};
146146
var verboseOption = new Option<bool>("--verbose", "-v") { Description = "Verbose output" };
147147
var subscribeOption = new Option<bool>("--subscribe", "-s") { Description = "Subscribe" };
148+
var testallEndpointsOption = new Option<bool>("--testall", "--ea") { Description = "Test All Endpoints" };
148149
var reverseConnectOption = new Option<string>("--reverseconnect", "--rc")
149150
{
150151
Description = "Connect using the reverse connect endpoint. (e.g. --rc opc.tcp://localhost:65300)"
@@ -190,6 +191,7 @@ public static Task<int> Main(string[] args)
190191
jsonOption,
191192
verboseOption,
192193
subscribeOption,
194+
testallEndpointsOption,
193195
reverseConnectOption,
194196
foreverOption,
195197
leakChannelsOption,
@@ -239,6 +241,7 @@ public static Task<int> Main(string[] args)
239241
bool enableDurableSubscriptions =
240242
parseResult.GetValue(durableSubscriptionOption);
241243
var serverUrl = new Uri(parseResult.GetValue(serverUrlArgument));
244+
var testallEndpoints = parseResult.GetValue(testallEndpointsOption);
242245

243246
ReverseConnectManager reverseConnectManager = null;
244247
using var telemetry = new ConsoleTelemetry();
@@ -290,7 +293,7 @@ public static Task<int> Main(string[] args)
290293
logConsole,
291294
fileLog,
292295
appLog,
293-
LogLevel.Information);
296+
LogLevel.Warning);
294297

295298
// delete old certificate
296299
if (renewCertificate)
@@ -325,6 +328,21 @@ await application.DeleteApplicationInstanceCertificateAsync(ct: cancellationToke
325328
CancellationToken ct = quitCTS.Token;
326329
ManualResetEvent quitEvent = ConsoleUtils.CtrlCHandler(quitCTS);
327330

331+
// handle connect all endpoints test.
332+
if (testallEndpoints)
333+
{
334+
var tester = new ClientSamples(
335+
telemetry,
336+
null,
337+
quitEvent,
338+
verbose);
339+
340+
if (await tester.RunAsync(quitEvent, ct).ConfigureAwait(false))
341+
{
342+
return;
343+
}
344+
}
345+
328346
var userIdentity = new UserIdentity();
329347

330348
// set user identity of type username/pw

Applications/ConsoleReferenceClient/Quickstarts.ReferenceClient.Config.xml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -65,7 +65,7 @@
6565
<!-- WARNING: The following setting (to automatically accept untrusted certificates) should be used
6666
for easy debugging purposes ONLY and turned off for production deployments! -->
6767
<AutoAcceptUntrustedCertificates>false</AutoAcceptUntrustedCertificates>
68-
<!-- WARNING: SHA1 signed certificates are by default rejected and should be phased out.
68+
<!-- WARNING: SHA1 signed certificates are by default rejected and should be phased out.
6969
only nano and embedded profiles are allowed to use sha1 signed certificates. -->
7070
<RejectSHA1SignedCertificates>true</RejectSHA1SignedCertificates>
7171
<RejectUnknownRevocationStatus>true</RejectUnknownRevocationStatus>

0 commit comments

Comments
 (0)