Commit Graph
1862 Commits
Author SHA1 Message Date
Martin Regen ef645f63e7 Merge pull request #2944 from OPCFoundation/develop/main374
Merge develop/main374 in release branch
1.5.374.168
2025-01-20 13:25:08 +01:00
Martin Regen 61056d0d30 Some .NET 9 maintenance and JSON encoder improvements (#2922)
- Reduce memory allocations in JSON encoder by using stackalloc/ArrayPool
- Fix some new warnings in .NET9 code analyzers
- Fix fuzzing error in JsonDecoder
- do not use .NET9 libraries with .NET8 LTS builds #2931, #2940
- Bump langversion to 9 (max VS2019)
- Use official ASP.Net 2.3. libraries for .NET Framework (rel. Jan 15th)
2025-01-20 08:45:12 +01:00
Martin Regen a0b12d7116 Fix race condition on Nuget build (#2930)
- nodeset xmlzip is created in obj folders if multiple targets are built in parallel
2025-01-16 21:33:41 +01:00
Martin Regen 8d234e2028 Merge pull request #2928 from OPCFoundation/cherrypicks
Merge cherrypicks from master in develop branch
2025-01-08 15:41:36 +01:00
romanett d133ec1159 Add SetHiResClockDisabled & fix Rejected Store Creation in ApplicationConfigurationBuilder (#2909)
Add the method SetHiResClockDisabled to IApplicationConfigurationBuilder
Fix the type of RejectedStore Created by the Builder to: CertificateStoreIdentifier
2025-01-08 13:59:46 +01:00
Stephan Larws df881be3ac Handle status code Uncertain according to the specification (#2898)
* #2896: Write output arguments for good and uncertain status code

When a method state's call method is invoked the output arguments should be written in case the status code is good or uncertain. This behavior would be conform with the current specification.

* #2896: The service result corresponds the method call result

The result of the Call method in the CustomNodeManager2 class represents the status of the CallMethodResult. It does not correspond to the ServiceResult of the CallResponse, thus returning Good as a general response is incorrect behavior.
2025-01-08 13:36:41 +01:00
romanett 444b2c8e51 Add port number check in the MatchEndpoints method to ensure the correct endpoint is returned (#2925) 2025-01-07 17:08:23 +01:00
romanett de688aca18 [Server] Improve GetManagerHandle & introduce a threadSafe NodeIdDictionary (#2915)
* Make NodeIdDictionary threadsafe by changing the underlying dict from `Dictionary` to `ConcurrentDictionary`
* reduce blocking in CustomNodeManager2 for GetManagerHandle & other uncritical supporting functions
2024-12-19 17:17:25 +01:00
Martin Regen 9a434b860c Fix misc. build issues and warnings (#2908)
- Fix errors and warnings on stricter build systems.
- Some Linux distri do not support brainpool, detect if tests can be run.
2024-12-13 17:41:14 +01:00
Martin Regen dc661bac46 Fix server CurrentTime source timestamp and improve readerwriter locks (#2903)
Fix server time source timestamp is not updated.
There are duplicate objects in generated code, on of which which holds the last timestamp was not updated.

Move all readerwriter locks outside of try/finally to avoid a SynchronizationLockException when a reader writer lock is disposed or is cancelled.

Currently there is no obvious fundamental bug in how the readerwriter locks are used, but outside the try/finally clause e.g. a disposed lock may not trigger a false exception.
2024-12-13 08:59:28 +01:00
romanett f431d53c89 Fix Null reference Exception in NodeState for AccessRestrictions (#2894)
* fix cast that throws when Enum is null
2024-12-11 08:48:09 +01:00
romanett 67a0df1960 Fix read of NodeId attribute AccessRestrictions by casting return type from Enum to ushort (#2883)
In the read NodeId servcie call an enum is by default cast to Int32, so the cast to ushort is needed here to return the expected type for the AccessRestrictions.
2024-12-05 08:39:09 +01:00
Martin Regen f5d00d934c Merge pull request #2881 from OPCFoundation/main374releaseconflict
Merge develop/main374 into release/1.5.374
1.5.374.158
2024-12-04 11:22:26 +01:00
Martin 8ea1aa430c merge release/1.5.374 2024-12-04 10:02:33 +01:00
romanett 6c62eb26fd Fix serialization of CertificateTrustList (#2879) 2024-12-04 09:42:19 +01:00
Suciu Mircea AdrianandMartin Regen d0e89a3bf1 Support mutual TLS on server https endpoints (#2849)
A new configuration variable 
    <HttpsMutualTls>true</HttpsMutualTls>
enables the mutual TLS authentication support. The behavior of the TLS endpoint changes as the following:

HttpsMutualTls is true:
The server checks the trust on the certificate which is used by the client for TLS authentication. It must be a valid OPC UA application certificate which is trusted.
A client can still connect without providing a client certificate, but then it is only able to call discovery services.
In order to create a session, the client must use the same application certificate that was used for the TLS channel.

HttpsMutualTls is false:
- There is no application authentication. The server endpoint uses security None and there is no client application authentication.
Instead, only user authentication is used to secure the server, anonymous user authentication is disabled.
Discovery service calls are supported.

Co-authored-by: Martin Regen <mregen@microsoft.com>
2024-12-03 12:43:39 +01:00
Martin Regen a887f909f1 Allow ExtensionObjects which are encoded with an unknown size (#2869)
An older OPC UA server returns well known extension object(811) which cannot be decoded by the client because the server doesn't set the length of the extension object. 
Recently, based on fuzz testing, the length check has been changed to enforce an exact match, according to spec.

Workaround: Allow a value of -1 for the length, then allow to decode well known extension objects.

Also improve some internal calls to Safe Read functions by calling not via the interface.
2024-12-03 12:06:11 +01:00
Martin Regenanddependabot[bot] 71a6e69d62 Bump BouncyCastle.Cryptography from 2.4.0 to 2.5.0, Serilog and Codecov (#2875)
* bump bouncy castle to 2.50

* Bump codecov/codecov-action from 4 to 5 (#2847)

Bumps [codecov/codecov-action](https://github.com/codecov/codecov-action) from 4 to 5.
- [Release notes](https://github.com/codecov/codecov-action/releases)
- [Changelog](https://github.com/codecov/codecov-action/blob/main/CHANGELOG.md)
- [Commits](https://github.com/codecov/codecov-action/compare/v4...v5)

---
updated-dependencies:
- dependency-name: codecov/codecov-action
  dependency-type: direct:production
  update-type: version-update:semver-major
...

Signed-off-by: dependabot[bot] <support@github.com>
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>

* Bump Serilog and System.Diagnostics.DiagnosticSource (#2818)

Bumps [Serilog](https://github.com/serilog/serilog) and [System.Diagnostics.DiagnosticSource](https://github.com/dotnet/runtime). These dependencies needed to be updated together.

Updates `Serilog` from 4.0.2 to 4.1.0
- [Release notes](https://github.com/serilog/serilog/releases)
- [Commits](https://github.com/serilog/serilog/compare/v4.0.2...v4.1.0)

Updates `System.Diagnostics.DiagnosticSource` from 6.0.1 to 8.0.1
- [Release notes](https://github.com/dotnet/runtime/releases)
- [Commits](https://github.com/dotnet/runtime/compare/v6.0.1...v8.0.1)

---
updated-dependencies:
- dependency-name: Serilog
  dependency-type: direct:production
  update-type: version-update:semver-minor
- dependency-name: System.Diagnostics.DiagnosticSource
  dependency-type: direct:production
  update-type: version-update:semver-major
...

Signed-off-by: dependabot[bot] <support@github.com>
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>

---------

Signed-off-by: dependabot[bot] <support@github.com>
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
2024-12-03 11:25:58 +01:00
Martin Regen af7dc0f59d Merge pull request #2878 from OPCFoundation/mastercherrypicks
Merge fixes from master in stable branch
2024-12-03 10:55:36 +01:00
romanett 6f7b8e7cf7 [Client] Fix: KeepAliveInterval was not updated on ModifySubscription (#2871)
* Bug fix for: keep alive timer is not updated if the timing of a subscription is changed #2863
* Restart KeepAlive Timer with correct KeepAliveInterval on ModifySubscription, if the interval changed
2024-12-03 10:47:33 +01:00
Archie Miller f98c8a9e23 Client fix for ConditionRefreshAsync always returns NodIdUnknown, add ConditionRefresh2Async support(#2876)
Fixes #2854
2024-12-03 10:24:07 +01:00
Archie Miller ab364b9e98 Update CauseMappings to reflect issue (#2877)
SyspendedToRead caused by Reset remains as per Part 10 Table 7
2024-12-03 10:23:56 +01:00
Martin RegenandMarc Schier 1fa0b7f26e Register callback to notify about new channel token activation (#2872) (#2873)
For better client diagnostic it is important to have access to the channel token. Today tooling must monitor the channel token change to be aware of the current token, it is more efficient for the tooling to be called back when the token changes. This can be now accomplished in that the owner of a client (Discovery, Session) can retrieve the Transport channel after connect, read the current token and register a change callback.

* Add OnTokenActivated event for token change notifications

Added a new event `OnTokenActivated` to the `UaChannelBase` class in the `Opc.Ua` namespace to notify when a channel token is activated. Implemented this event in the `HttpsTransportChannel` class within the `Opc.Ua.Bindings` namespace. Introduced a protected internal `OnTokenActivated` event handler in the `UaSCBinaryChannel.Symmetric` class, invoked during token changes in the `ActivateToken` and `DiscardTokens` methods. Cleaned up the event handler in the `Dispose` method of the `UaSCBinaryClientChannel` class. Registered the event handler with the internal channel in the `UaSCBinaryTransportChannel` class. Added a new delegate `ChannelTokenActivatedEventHandler` in the `ITransportChannel` interface and updated the interface to include the `OnTokenActivated` event. Made minor formatting and comment adjustments for improved readability and consistency.

* Include channel in callback

Co-authored-by: Marc Schier <marcschier@users.noreply.github.com>
2024-12-02 11:21:07 +01:00
Martin Regen 0a4804f4c5 Client perf and memory improvements for JSON encoding and subscriptions (#2864)
- reduce EscapeString overhead in JSON encoder
- client monitored items: allocate queues only if needed
- replace SortedDictionary with Dictionary for perf reasons
- revert a change in padding and reduce a log level
2024-11-28 21:32:55 +01:00
Martin Regen f76c457c72 Support .NET 9.0 build (#2865)
* support .NET 9.0 build
* provide a helper to use the X509CertificateLoader also on older .NET versions
2024-11-28 12:57:10 +01:00
romanett 2f21ca8853 [Server] ValidateRolePermissions of MonitoredItems based of the saved user identity to allow validation when no session is present (#2832)
* ValidateRolePermissions for MIs montioring the Value of a Node
* allow validation of user identity also in case of disconnected session
2024-11-28 09:52:02 +01:00
Salih Goncu ed78fcee04 Merge pull request #2809 from romanett/MIFixRolePermissions
ValidateRolePermissions for MIs montioring the Value of a Node
2024-11-24 10:54:06 +01:00
Suciu Mircea Adrian 3543d02925 Added a minimal rogue client detection mechanism at the transport level (#2850)
Clients that are failing too often to pass the security validationin a certain interval of time with the Basic128 security profile are now tracked and blocked.
2024-11-22 10:01:30 +01:00
Martin Regen 76b53184de ChannelToken: Dispose HMAC and improve lifetime calculations. (#2846)
- Channels are not disposed (client and server)
- During long running tests an HMAC object leak was observed.
- The HMAC and SymmetricSign objects were not disposed after use, leading to a small incremental memory leak per key renewal. 
- The channel token lifetime is calculated by the system clock, which can change. Instead use the continous HiResClock.TickCount to calculate the lifetimes.
- Token renewal and connection requests are not removed from the request dictionary

Improvements:
- Make ChannelToken disposable. Dispose channels.
- Dispose HMAC and SymmetricSign objects after use.
- Use TickCount to calculate key renewal and key expiry.
- Introduce a 5% jitter to the token renewal timer, to avoid token renewal storms.
- Reduce the allocation per use of the HMAC objects by using ReadOnlySpan and avoid MemoryStream.
2024-11-21 10:16:13 +01:00
KircMax 56dd06d97f Using Uri.TryCreate causes regression with namespace uri that use mixed lower/uppercase letters in the <hostname> of the Uri.(#2837)
Uri.TryCreate lower cases the hostnames. Switch always back to the legacy implementation which maintains the casing.
2024-11-07 10:31:18 +01:00
romanett ff3674fe58 Improve crl handling in certificate stores (#2829)
* improve crl handling in certificate stores by not loading CRL with invalid or unsupported content. Hence the revocation check for such certificates may fail.
2024-11-02 11:44:51 +01:00
Suciu Mircea Adrian 787844c011 Update brokerHostName before MqttClientOptionsBuilder uses it's value (#2830) 2024-10-31 21:03:55 +01:00
Martin Regen ce9850c491 Fix bugs in JSON decoder (#2828)
JSON ReadEnumeratedString does not decode the number in e.g. "Red_0".
JSON reencode of JSON content in an extension object runs into an encoder error.
2024-10-31 08:02:32 +01:00
Martin Regen b3b2f9154e Update version.json to allow preview builds from develop (#2813) 2024-10-26 09:39:04 +02:00
Martin Regen d60adc197a IOP: Fix FetchOperationLimits for some use cases (#2807)
* an exception in FetchOperationLimits may have skipped applying the configured operation limits on the server
2024-10-24 12:55:40 +02:00
romanett 16b9aeff4d Add ReturnDiagnostics to Session Constructor (#2810)
returndiagnostics was not propagated to recreated and reconnected sessions
2024-10-24 05:49:26 +02:00
Roman Ettlinger dfa4c9a122 fix typo 2024-10-23 17:47:11 +02:00
Roman Ettlinger 4bee42cef6 ValidateRolePermissions for MIs montioring the Value of a Node 2024-10-23 17:42:30 +02:00
Martin RegenandMarc Schier 0b23e5f39b Null pointer exception when reading a complex type with empty arrays. (#2798) (#2799)
The server under test has a extension object with a complex type.  Type id = {nsu=http://opcfoundation.org/UA/Machinery/Result/;i=5008}.  This contains something with a variant array that is null though (-1).  SetProperty should support setting a Array that is null.  Therefore, test for null collection (case when length was encoded as -1) before dereferencing ahead of the ToArrray() conversion to Array.

Co-authored-by: Marc Schier <marcschier@users.noreply.github.com>
1.5.374.126
2024-10-14 18:49:29 +02:00
Marc Schier 3672ebefe9 Null pointer exception when reading a complex type with empty arrays. (#2798)
The server under test has a extension object with a complex type.  Type id = {nsu=http://opcfoundation.org/UA/Machinery/Result/;i=5008}.  This contains something with a variant array that is null though (-1).  SetProperty should support setting a Array that is null.  Therefore, test for null collection (case when length was encoded as -1) before dereferencing ahead of the ToArrray() conversion to Array.
2024-10-14 17:18:50 +02:00
Martin Regen 6ca0b1a78e Cherry pick: Fix ExpandedNodeId.Format output for not well formed uri and JSON Verbose WriteStatusCode (#2795)
-JSON Encoder Verbose and NonReversible encoding with WriteStatusCode may produce invalid JSON
-ExpandedNodeId.Format does not handle not well formed uri correctly, as in the previous implementation
2024-10-13 08:17:37 +02:00
Martin Regen cb621df562 Fix ExpandedNodeId.Format output for not well formed uri and JSON Verbose WriteStatusCode (#2794)
-JSON Encoder Verbose and NonReversible encoding with WriteStatusCode may produce invalid JSON
-ExpandedNodeId.Format does not handle not well formed uri correctly, as in the previous implementation
2024-10-11 19:15:26 +02:00
Martin Regen 0215eb5552 Revert "#2656 Fix for - Session is not provided by ClearChangeMasks when a change is notified (#2772)" (#2792)
This reverts commit 9c7b321ecb.
During manual tests the new code ran into an ArgumentNullException creating a new OperationContext.
2024-10-11 13:27:04 +02:00
Filippo-Oliva-ABB 9c7b321ecb #2656 Fix for - Session is not provided by ClearChangeMasks when a change is notified (#2772)
It fixes #2656 by including in the SystemContext (taken as an argument to the OnMonitoredNodeChanged method) the Server session related to the current MonitoredItem that is going to be passed to the QueueValue.
2024-10-10 19:56:28 +02:00
ThomasNehring 44dc73460a Move modified ref test server to own file (#2725)
Moved the modified reference server from the unit test to its own file. 
Also moved the modified server side session, the modified session manager and the modified master node manager to the same file.
2024-10-10 19:39:20 +02:00
romanett 014808e5d8 [Server] update endpoint descriptions after certificate update (#2735)
- Update the Server Endpoint Descriptions after certificate update e.g. from a GDS Push.
Until this PR the server needed a restart.
2024-10-10 19:35:21 +02:00
Filippo-Oliva-ABB 711160e84a #2777 Fix for - MonitoredItem2.OnReportEvent Ignores Session in ISystemContext During Notification Process (#2779)
Check the Session included in the ISystemContext instance, if any, and compare it with those belonging to the monitored items.
If the ISystemContext instance contains a Session, the event will be appended only to the monitored items belonging to the same Session.
If the ISystemContext instance does not contain a Session, the event will be appended to all monitored items, regardless of their sessions.
2024-10-10 11:33:38 +02:00
Martin Regen 23b8502778 Server doesn't start up with mixed https endpoints (#2789)
* allow startup of mixed https endpoints
2024-10-10 07:01:48 +02:00
ThomasNehring a29d871711 [Client] Read large dictionaries in chunks (#2782)
A new method is implemented which reads byte strings in chunks and therefore allows to read byte strings which exceed the encoding limits of the server. This is used in the method which reads v103 data dictionaries.
2024-10-09 11:30:49 +02:00
Martin Regen 7c63d8a18f Client ReadNodes, throw BadInvalidType if a value type returned by an attribute is null (#2746)
Handle a case where a misconfigured server returns a null value for an attribute when a value type is expected. To avoid the NullReferenceException that stops the whole ReadNodes operation, flag the Node with the service result and or return a default value if required.
2024-10-09 10:12:28 +02:00