22 Commits

Author SHA1 Message Date
Marc Schier 70b4498db8 Certificate manager and ref counted certificate type (#3688)
* New certificate and secrete abstraction with certificate infrastructure and certificate/secret stores. 
* leak testing for certificate resources to validate new ref counting in every test assembly
* Migration guide updated and documentation added for all
* Remove IDisposable from Nodestate and UserIdentity.
* UserCertificateTokenHandler now just points into certificate registry/stores, no dispose required
* Fix CA2000 warnings and cleanup of other diagnostics, increase warning levels in .editorconfig
2026-05-12 07:56:38 +02:00
Marc Schier d1883832e1 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 5e627f2ca1 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>
2026-04-16 18:56:42 +00:00
Marc Schier 64ca85fce3 Increase code coverage across solution (#3662)
Add additional tests to increase code coverage across the solution
2026-04-14 13:32:10 +02:00
Marc Schier fd41681f4b Add support to publish OPC UA applications as Native AOT (#3633)
* make most ptojects aot compatible
* Remove newtonsoft
* Migrate all projects from Mono.Options to System.CommandLine 2.0.5
* Fix array clone
* Replace serializers for storage using new attribute driven  type geberator
* Add new AOT integration tests covering all functional areas
* Documentation updates
2026-04-13 20:52:29 +02:00
Copilot edbbfa3532 Add tests for ServerBase with multiple IP addresses on the same port & improve CI Stability (#3650)
* Add tests for server with multiple IP addresses on same port

Agent-Logs-Url: https://github.com/OPCFoundation/UA-.NETStandard/sessions/adce15e6-8c71-4ba9-8581-cb526b274dfe

Co-authored-by: romanett <7413710+romanett@users.noreply.github.com>

* Fix flaky RequestQueueTests by using separate CancellationTokenSources per wait

Agent-Logs-Url: https://github.com/OPCFoundation/UA-.NETStandard/sessions/85e9cbc6-7d42-4e6b-8cbe-725b732c72a2

Co-authored-by: romanett <7413710+romanett@users.noreply.github.com>

* Fix flaky VerifyRejectedCertsDoNotOverflowStoreAsync test

Agent-Logs-Url: https://github.com/OPCFoundation/UA-.NETStandard/sessions/a75f2420-077e-4022-8f73-17b52d6de841

Co-authored-by: romanett <7413710+romanett@users.noreply.github.com>

* Fix race in RequestQueueTests: await req3 completion before asserting status code

Agent-Logs-Url: https://github.com/OPCFoundation/UA-.NETStandard/sessions/43e310a1-bcf1-45fd-84f1-f5266b1e855d

Co-authored-by: romanett <7413710+romanett@users.noreply.github.com>

* Fix flaky TransferSubscriptionOnlyAsync(DisconnectedRepublishDelayedAck): poll for republished notifications and use GreaterThanOrEqualTo assertion

Agent-Logs-Url: https://github.com/OPCFoundation/UA-.NETStandard/sessions/266c66da-e8dc-450f-925a-e3c1c50100b3

Co-authored-by: romanett <7413710+romanett@users.noreply.github.com>

* Fix ShortHaulStabilityTestAsync: wait for initial subscription notifications before starting writes, reset counters for clean measurement window

Agent-Logs-Url: https://github.com/OPCFoundation/UA-.NETStandard/sessions/44e73c6c-3620-4e88-9f4c-852a9fe58d94

Co-authored-by: romanett <7413710+romanett@users.noreply.github.com>

* Fix TransferSubscriptionOnlyAsync(DisconnectedRepublishDelayedAck,False,False): extend republish polling to all sendInitialValues combinations

Agent-Logs-Url: https://github.com/OPCFoundation/UA-.NETStandard/sessions/e5775ceb-1441-4bef-a9b7-7e80d5a9fb72

Co-authored-by: romanett <7413710+romanett@users.noreply.github.com>

* Fix TransferSubscriptionOnlyAsync(DisconnectedRepublishDelayedAck,False,*): restrict republish poll and expected count to sendInitialValues=True

Agent-Logs-Url: https://github.com/OPCFoundation/UA-.NETStandard/sessions/dbee6fa2-6ea3-4086-b36e-263288cfdf31

Co-authored-by: romanett <7413710+romanett@users.noreply.github.com>

* Fix RequestQueue race: increment m_totalThreadCount before Task.Run to prevent spurious worker spawning

Agent-Logs-Url: https://github.com/OPCFoundation/UA-.NETStandard/sessions/380346b7-7b31-4390-9438-3725028a0831

Co-authored-by: romanett <7413710+romanett@users.noreply.github.com>

---------

Co-authored-by: copilot-swe-agent[bot] <198982749+Copilot@users.noreply.github.com>
Co-authored-by: romanett <7413710+romanett@users.noreply.github.com>
2026-04-07 12:45:02 +02:00
Copilot f859245ebe Add unit tests for Server Subscription and Session handling (#3639)
* Add comprehensive unit tests for Server Subscription and Session handling

- SubscriptionLifecycleTests.cs: 46 tests covering subscription lifecycle
  (constructor, modify, publish mode, queue overflow, session closed,
  publish timeout, republish, durable subscriptions, triggering, etc.)
- SessionExtendedTests.cs: 29 tests covering session operations
  (expiry, channel validation, locale updates, continuation points,
  diagnostics, ValidateRequest, etc.)

All 578 tests pass (503 existing + 75 new).

Co-authored-by: romanett <7413710+romanett@users.noreply.github.com>
Agent-Logs-Url: https://github.com/OPCFoundation/UA-.NETStandard/sessions/d28cf5ce-a461-4e95-b23f-689ec5f5113b

* Remove all #region/#endregion directives from new test files

Agent-Logs-Url: https://github.com/OPCFoundation/UA-.NETStandard/sessions/a845e70e-0caa-4ed9-b694-c696b38b7e73

Co-authored-by: marcschier <11168470+marcschier@users.noreply.github.com>

* Fix net472 build: replace ValueTask.CompletedTask with default(ValueTask)

Agent-Logs-Url: https://github.com/OPCFoundation/UA-.NETStandard/sessions/36d75700-6e4a-4183-909a-95215e97932d

Co-authored-by: marcschier <11168470+marcschier@users.noreply.github.com>

* merge

* cleanup

* fix

---------

Co-authored-by: copilot-swe-agent[bot] <198982749+Copilot@users.noreply.github.com>
Co-authored-by: romanett <7413710+romanett@users.noreply.github.com>
Co-authored-by: marcschier <11168470+marcschier@users.noreply.github.com>
Co-authored-by: Roman Ettlinger <romanett98@gmail.com>
2026-03-31 10:13:52 +02:00
romanett 23f10d89ee [Server] Introduce RequestLifetime for request handling and cancellation (#3643)
Use RequestLifetime throughout the server stack for unified request lifetime and cancellation management. Update all service method signatures, OperationContext, and request processing logic to use RequestLifetime, enabling precise tracking of cancellation reasons with UA StatusCodes. Remove obsolete synchronous request handling and legacy delegates. Update code generation, tests, and interfaces to support the new model. This change improves cancellation, timeout, and abort handling, and prepares the server for advanced request management features.
2026-03-30 13:17:19 +02:00
romanett 66f44396ff [Server] Improve Request Queue, fix Event handling, add Tests (#3611)
- implement RequestQueue using Channels
- add event load test
- add event integration test verifying event from server object is received
- fix Client Reconnect Test
- fix DiagnosticsNodeManager not creating RootNotifier for Server object
- add Benchmarks for MonitoredItem.QueueEvent
- add serveral UnitTest for DiagnosticsNodeManager
Co-authored-by: copilot-swe-agent[bot] <198982749+Copilot@users.noreply.github.com>
Co-authored-by: romanett <7413710+romanett@users.noreply.github.com>
Co-authored-by: Marc Schier <marcschier@users.noreply.github.com>
2026-03-20 08:09:51 +01:00
Marc Schier 5a1e547250 Code cleanup and modernization of test assertions to comply with project standards. (#3631) 2026-03-19 21:09:40 +01:00
Marc Schier 03777ecb09 New Json decoder/encoders, array/matrix abstractions, ByteString, and more. (#3619)
- **Collections overhaul** — new/rewritten collection types (`ArrayOf`, `Collections` commits)
- **`Variant` builder/accessor** — new APIs for constructing and accessing Variants
- **`NodeId` operators made explicit** — breaking change for implicit conversions
- **Version bumped to 1.6** with preview build support
- **NumericRange** uses Variant
- **object** type accessors and general usage removed.

### 🏗️ Infrastructure
- Build config updated; `.NET 10` targeting
- InternalsVisibleTo moved to `.csproj`
- Pipeline/CI adjustments
2026-03-18 12:23:30 +01:00
Marc Schier 601cabf86f Replace all use of object in code and API with Variant (#3550) 2026-02-15 06:19:38 +01:00
Marc Schier f66ceffd75 Immutable built in types and code generation (#3534)
Generate stack and application code using source generators
Change built in types to readonly structs
  Update localized text implementation to use JSON text serializer
  Status code with symbolic names
  Immutable node ids
  No boxing for all built in types <= 8 bytes in Variant.
Split user identity token and token handling via token handler
Add migration guide for breaking changes
2026-02-12 16:27:07 +01:00
raserle 029a8fbaa6 [Server] Fix generation of UserTokenPolicyIDs (#3525)
* add Equals, change id generation

* add equality operators and gethashcode

* add override Equals

* Copilot issues

* fix TranslateEndpointDescriptionsTest, that relied on ServerUnique UserTokenPolicy Ids

---------

Co-authored-by: Roman Ettlinger <romanett98@gmail.com>
2026-02-11 13:36:28 +01:00
Marc Schier 2960388560 Update headers and license files (#3388)
Update license headers to copy right year 2025, replace RCL/GPL headers with MIT, replace the nuget license with MIT (via license expression).
2025-12-04 19:44:40 +01:00
Marc Schier 712e770fbe Restructure core and built in types into base assembly and nuget (#3326)
This change adds a **new Opc.Ua.Types** nuget that contains core types that do not rely on generated code.  Why the name?  Because almost all code that was in the Types subfolder is part of it, and because we do not want to change the name of the Opc.Ua.Core nuget/assembly because code relies on it.  Any other name like base or bootstrap felt out of place due to the current structure already defining the name "types".  Key design is to depend on only a small set of libraries with limited transitive dependencies, that includes hashcode, logging.abstraction, and for non standard20 builds System.Text.Json (needed for localizedText mul parsing).  Also, key is to support .netstd 2.0 to support source generators and to allow removal of EEC_SUPPORT defines by removing std2.0 from core and all libraries.

The changes are mostly restructuring, and thus small but contain some key changes:

- **Status code** struct now comes with a Symbol field, which is used to carry symbols in case the code is not generated.  Currently (until generated) the status code struct must be manually created with a symbol or the ToSymbolicId extension must be called in the core project.  Future will generate Status code constants just like NodeId that contain the symbol which also removes the reflection-based lookup.  Several tests needed to be adjusted as they checked the status code symbol strings instead of the code.
- **Core identifiers** are copied as they were needed for code to compile, that includes attributes, a subset of status codes and node identifiers.  These will never change so no need to generate them.
- The types folder now contains **encoders**, except for json which is still in core.  Once the json encoder is ported to system.text.json it will also be included and Newtonsoft.Json dropped as dependency (-> #3329).  
- Since types relies on **IOperationContext** and **ISystemContext**, and these export IUserIdentity which relies on crypto, these were split and extended in core with ISessionOperationContext and ISessionSystemContext, which mean changes to ServerSystemContext and introduction of SessionOperationContext and SessionSystemContext classes that extend OperationContext and SystemContext.  Some runtime checks in the server are therefore needed to get at the session and auth info, however, those are anyway optional fields and are not on the critical paths, and thus a type check is in order (and was done in the past already, but against OperationContext class).
- **Manifest resources** are now split between Core (nodeset zip, some generated resoures) and Types (built in bsd/xsds).  This needs to be revisited later if the bsd/xsd need to be regenerated during type generation.  Note that the embedded resource names changed as a result. Since these are only used internally and do not constitute public API this feels reasonable vs duplication of resources in 2 assemblies.
- Reflection however now needs to load not just the built in **encodeables** from Opc.Ua.Types assembly, but also the generated encodeables from Opc.Ua.Core assembly.  For this a new helper Utils method was added to get the Core assembly when linked against Opc.Ua.Core otherwise null.
- Whatever utils methods needed to be split out into the new Opc.Ua.Types assembly, they are now in **CoreUtils** static class in Opc.Ua.Types, and Utils.xxxx forwards to them to ensure minimal changes.  Later we would want to obsolete them in favor of CoreUtils, although it might make sense to split them again into domain specific utilities, such as networking, files, etc
2025-11-10 19:33:24 +01:00
Copilot 8c9ccc4477 Replace deprecated Uri.DnsSafeHost with Uri.IdnHost (#3256)
* Replace deprecated Uri.DnsSafeHost with Uri.IdnHost across codebase

Co-authored-by: marcschier <11168470+marcschier@users.noreply.github.com>

* Update Kestrel.Core package version to 2.3.6
* Fix privateKeyPassword handling in GDS client

---------

Co-authored-by: copilot-swe-agent[bot] <198982749+Copilot@users.noreply.github.com>
Co-authored-by: marcschier <11168470+marcschier@users.noreply.github.com>
Co-authored-by: Marc Schier <marcschier@hotmail.com>
Co-authored-by: Marc Schier <marcschier@users.noreply.github.com>
2025-10-16 08:18:04 +02:00
Marc Schier 8e7a73c7df Introduce telemetry context and proper use of ILogger (#3213) 2025-09-25 20:25:31 +02:00
Marc Schier 9830e5d53e Enable roslynizer and fix all analyzer issues (#3157)
* Fix warnings and suggestions
* Enable roslynator
2025-08-16 04:10:24 -07:00
dependabot[bot] 60689c9431 Bump NUnit from 3.14.0 to 4.1.0 (#2535)
* Bump NUnit from 3.14.0 to 4.1.0

Bumps [NUnit](https://github.com/nunit/nunit) from 3.14.0 to 4.1.0.
- [Release notes](https://github.com/nunit/nunit/releases)
- [Changelog](https://github.com/nunit/nunit/blob/master/CHANGES.md)
- [Commits](https://github.com/nunit/nunit/compare/v3.14.0...4.1.0)

---
updated-dependencies:
- dependency-name: NUnit
  dependency-type: direct:production
  update-type: version-update:semver-major
...

Signed-off-by: dependabot[bot] <support@github.com>

* fix Build by adding: using Assert = NUnit.Framework.Legacy.ClassicAssert;

Co-authored-by: Roman Ettlinger <romanett98@gmail.com>
2024-04-22 13:29:30 +02:00
Martin Regen 61edad9d63 Ensure endpoints are returned when alternate url port does not match (#2511)
- fix NormalizeHostName when host ip addresses are not returned on macOS, try the native hostname
- Ensure endpoints are returned even if the client url port do not match (similar to client)
- Improve endpoint tests
2024-02-17 07:31:10 +01:00
Suciu Mircea Adrian d573eaa01b Fix TranslateEndpointDescriptions (#2495) 2024-02-06 14:12:14 +02:00
Bo Biene 7867a6fa7e Fix GetEndpoints when https-uabinary is behind reverse proxy with different port (#2362)
Fix: When the port of AlternateBaseAddress is different from the Endpoint port the discovery returns no valid endpoints.

Co-authored-by: Martin Regen <mregen@microsoft.com>
2024-01-19 10:32:26 +01:00