feat(dcl): move the OPC UA client to OPC Foundation SDK 2.0.1 (#125)

OPCFoundation.NetStandard.Opc.Ua.Client and the test-only .Server move
1.5.378.182 -> 2.0.1, the version OtOpcUa master runs (lmxopcua#782; #799
and #801 closed). Transitive Core/Core.Types/Types/Configuration/
Security.Certificates resolve to 2.0.1.

API breaks fixed in the DCL adapter:
- Built-in types are immutable structs (Variant, DataValue, NodeId,
  LocalizedText, StatusCode, ArrayOf<T>). New OpcUaValueBoundary restores
  the SDK 1.5 CLR shapes for every read, subscription and alarm-event
  value (byte[], UTC DateTime with no-timestamp = MinValue, Guid,
  detached arrays) and builds write variants with SDK 1.5's
  new Variant(object) semantics (byte[] = ByteString scalar).
- StatusCodes members are no longer constants: switches/patterns over
  them (verify-outcome mapping, connection-level classification,
  BadResourceUnavailable) match by value.
- CertificateIdentifier no longer caches a certificate and the
  CertificateValidator/CertificateValidation event is gone: the
  configuration's CertificateManager owns trust lists and the loaded
  application certificate and is disposed with the session; auto-accept
  and the verify probe's capture-and-reject use AcceptError.
- new UserIdentity(X509Certificate2) is gone: X509 user identities use
  X509IdentityTokenHandler with an on-demand PFX provider (still fails
  fast on a missing file/key).
- DefaultSessionFactory takes the telemetry context; collections are
  ArrayOf<T>; EventFilter select clauses and ContentFilter operands are
  built immutably.

UserName identity (lmxopcua#880): SDK 2's default handler sends a
password over 64 bytes - every 65-character OtOpcUa API key - as an
RsaEncryptedSecret that SDK 1.5 servers reject with BadIdentityTokenInvalid
and SDK 2 servers accept only within a 5-minute clock window (#873). The
DCL now always uses LegacyRsaUserNameIdentityTokenHandler (ported from
OtOpcUa be28aa44), i.e. exactly what it sent on SDK 1.5, so it logs in to
both server generations during a mixed rollout.

Tests: the in-process secured test server is ported to SDK 2 and can
admit an API key; new tests cover the handler (mutation-checked: 5 of 7
fail with the SDK default handler), the value boundary, and a 65-char key
end to end over None/Sign/SignAndEncrypt with a wrong key reaching the
key check (BadIdentityTokenRejected).

Claude-Session: https://claude.ai/code/session_01GT67ACmpMR7b9LGRPLijMi
This commit is contained in:
Joseph Doherty
2026-11-12 22:02:53 -05:00
parent 95584e2fcb
commit a2e9d71824
24 changed files with 1003 additions and 248 deletions
+10 -9
View File
@@ -69,20 +69,21 @@
<PackageVersion Include="Microsoft.NET.Test.Sdk" Version="17.14.1" />
<PackageVersion Include="Microsoft.Playwright" Version="1.58.0" />
<PackageVersion Include="Moq" Version="4.20.72" />
<!-- 13.0.4 is the floor OPCFoundation.NetStandard.Opc.Ua.Core 1.5.378.x demands; surfaced when
CentralPackageTransitivePinningEnabled was turned on (Gitea #79). Also used by the
Commons.Tests contract-lock tests;
used by Commons.Tests contract-lock tests that exercise the Akka default JSON serializer. -->
<!-- 13.0.4 was the floor OPCFoundation.NetStandard.Opc.Ua.Core 1.5.378.x demanded, surfaced when
CentralPackageTransitivePinningEnabled was turned on (Gitea #79); SDK 2 dropped Newtonsoft from Core
(ScadaBridge#125). Still used by the Commons.Tests contract-lock tests that exercise the Akka default
JSON serializer. -->
<PackageVersion Include="Newtonsoft.Json" Version="13.0.4" />
<PackageVersion Include="Novell.Directory.Ldap.NETStandard" Version="3.6.0" />
<PackageVersion Include="NSubstitute" Version="5.3.0" />
<!-- 1.5.378.182 = the last SDK 1.5 build OtOpcUa ran before its 2.0.1 move (ScadaBridge#125). The 2.0.x
move waits for lmxopcua#799 and #801. Since .156, issuer CA certs need the keyCertSign KeyUsage, and
this also applies to server certs the DCL trusts. -->
<PackageVersion Include="OPCFoundation.NetStandard.Opc.Ua.Client" Version="1.5.378.182" />
<!-- 2.0.1 = the SDK OtOpcUa master runs (ScadaBridge#125, after lmxopcua#782/#799/#801 closed). The
transitive Core, Core.Types, Types, Configuration and Security.Certificates packages resolve to 2.0.1
under transitive pinning. Issuer CA certs need the keyCertSign KeyUsage (since 1.5.378.156), and SDK 2
never accepts an incomplete chain or an empty subject/issuer DN, even with AutoAcceptUntrustedCerts. -->
<PackageVersion Include="OPCFoundation.NetStandard.Opc.Ua.Client" Version="2.0.1" />
<!-- Test-only: in-process secured server for the Gitea #121 Sign/SignAndEncrypt tests.
Kept in lockstep with the client pin above. -->
<PackageVersion Include="OPCFoundation.NetStandard.Opc.Ua.Server" Version="1.5.378.182" />
<PackageVersion Include="OPCFoundation.NetStandard.Opc.Ua.Server" Version="2.0.1" />
<PackageVersion Include="OpenTelemetry.Api" Version="1.15.3" />
<!-- Parquet audit archival + the parquet format of `audit export` (ScadaBridge#42). 6.1.0 is fully
managed (Snappier / ZstdSharp / K4os LZ4, no native IronCompress) and NuGetAudit-clean. -->