1029 Commits

Author SHA1 Message Date
MarkusHorstmann eeea34f5a3 Array xmlns encoding/decoding always uses UA namespace(#2309)
XmlEncoder.WriteArray and XmlDecoder.ReadArray always use the OPC UA XML namespace (http://opcfoundation.org/UA/2008/02/Types.xsd) for the field element that contains the array, regardless of the namespace that the caller may have pushed.
2023-11-17 15:25:53 +01:00
Martin Regen 973d342b29 Implement the close async codepath (#2381)
- CloseAsync still used the 'Close' synchronous function
- remove a duplicate definition of IDisposable on ISession
- reduce the log output when the server publish time is out of sync
2023-11-17 14:41:26 +01:00
Martin Regen 4c0880c800 Fix codesmells. No functional changes and bug fixes. (#2368)
Fix many warnings to improve code quality or simplify the code.
2023-11-07 10:34:42 +01:00
Martin Regen 71ad9afd1c Nested complex types which contain structure derived from an abstract type are not correctly encoded (#2349)
- bug: if the nested complex type is derived from an abstract type like a Union, the decoder uses the abstract type instead of the actual type to decode
- fix: the loop to determine the supertype of the type to be decoded stops too early and returns an invalid type reference, e.g. for Unions. Instead the loop will now continue until a valid BuiltInType or a Structure or Enumeration type is found.
2023-10-26 11:06:26 +02:00
Martin Regen d47bc853da Various async improvements and minor issues found in IOP testing (#2346)
- improve various log messages, comments etc.
- multiple internal improvements in naming convention handling of async functions
- add FetchSuperTypesAsync
- replace new UTFEncoding() with Encoding.UTF8 singleton
2023-10-20 21:29:03 +02:00
Martin Regen ec4c3cd323 Add property to disable auto certificate creation on app startup (#2348)
- Add a property to `ApplicationInstance` to `DisableCertificateAutoCreation`
- Add the test case to validate property function
- Refactor some private API to follow coding style with `Async`suffix
- By default behavior is unchanged
2023-10-20 14:26:48 +02:00
Mikael Borg 49c8c00f5b .NET target 5.0 and 6.0 use 6.0 version of Microsoft.Extensions.Logging.Abstractions (#2335)
Referencing package OPCFoundation.NetStandard.Opc.Ua.Core from a .NET6 targeted project that in it self are using Microsoft.Extensions.Logging.Abstractions 6.0.4 will cause downgrade problems.

Instead for .NET6 targeted applications reference 6.0.x versions of Microsoft.Extensions.Logging.Abstractions.
2023-10-15 17:44:18 +02:00
tomaszras-intive 9f0f4c56ff Make CertificateValidationEventArgs and CertificateUpdateEventArgs constructors public (#2329)
Making these constructors public will unblock testing important scenarios.
2023-10-11 16:02:20 +02:00
Stefan Zschocke 88f2592962 Port to bouncycastle cryptography (#2315)
* Port to bouncycastle cryptography
* fix X509SignatureFactory.cs for latest bouncy castle
2023-09-26 20:41:49 +02:00
Marc Schier af04893a37 Fix degradation to sync calls in the SDK on main paths used. (#2316)
- make session create fully async incl. loading of the complex type system
2023-09-22 12:17:03 +02:00
Martin Regen 5af60ef6b6 Make async service call use awaitable, session open improvements (#2318)
- Improvements when many sessions need to be opened
- Introduce a OpenAsync version which usesmore async calls for session creation
- add async interfaces to cert validator 
- refactor lock of encodeable factory
- add a `EndAsync` property to WriteRequest to allow to await a service call
- add a `EndSendRequestAsync` method to allow implementation of awaitable service calls
2023-09-22 07:45:47 +02:00
Camille Guérin c75bf9be00 Removed extra unnecessary code and fixed use of userWriteMask (#2269)
- Removed extra unnecessary code in  CompareArray<T>
- Fixed userWriteMask in NodeState.cs
2023-08-25 14:48:28 +02:00
bhnaphade 4e6d58e1a4 Fix for 'BadTooManyOperations' in session.publish / 'BadServerHalted' when server is stopped. (#2277)
* Fixed status code when server is shutdown
* Add latest statuscodes from 1.05.03 to support new BadServerTooBusy error code
* added default throttle delay in case an unknown error is returned on a publish request service call
2023-08-22 20:02:39 +02:00
dependabot[bot] 7f864c1ef6 Bump Microsoft.AspNetCore.Server.Kestrel.Transport.Sockets (#2271)
Bumps [Microsoft.AspNetCore.Server.Kestrel.Transport.Sockets](https://github.com/dotnet/aspnetcore) from 2.1.3 to 2.1.40.
- [Release notes](https://github.com/dotnet/aspnetcore/releases)
- [Changelog](https://github.com/dotnet/aspnetcore/blob/main/docs/ReleasePlanning.md)
- [Commits](https://github.com/dotnet/aspnetcore/commits)

---
updated-dependencies:
- dependency-name: Microsoft.AspNetCore.Server.Kestrel.Transport.Sockets
  dependency-type: direct:production
...

Signed-off-by: dependabot[bot] <support@github.com>
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
2023-08-18 10:48:39 +02:00
dependabot[bot] 5f82d1b3d3 Bump Microsoft.Extensions.Logging.Abstractions from 3.1.32 to 7.0.1 (#2233)
* Bump Microsoft.Extensions.Logging.Abstractions from 3.1.32 to 7.0.1

Bumps [Microsoft.Extensions.Logging.Abstractions](https://github.com/dotnet/runtime) from 3.1.32 to 7.0.1.
- [Release notes](https://github.com/dotnet/runtime/releases)
- [Commits](https://github.com/dotnet/runtime/commits/v7.0.1)

---
updated-dependencies:
- dependency-name: Microsoft.Extensions.Logging.Abstractions
  dependency-type: direct:production
  update-type: version-update:semver-major
...

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

* Update Opc.Ua.Core.csproj

* Update UA Server Controls.csproj

* Update UA Client Controls.csproj

---------

Signed-off-by: dependabot[bot] <support@github.com>
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
2023-08-14 08:34:11 +02:00
bhnaphade c7381cf9f7 '#' is not treated as a reserved character in RelativePath's text format (#2264)
* updated reserve char check in RelativePath
* updated logic and added tests
2023-08-12 07:44:04 +02:00
Suciu Mircea Adrian cb99f46599 Fixed NodeId.CompareTo() null reference exception (#2263)
* Fixed NodeId.CompareTo() null reference exception when InnerNodeId is null
* more test cases and guid compare as described
* special null NodeId check test case
2023-08-11 22:23:19 +02:00
Martin Regen 82ed6c8ca8 Refactor IEncoder/IDecoder to derive from IDisposable (#2254)
- Currently the `IEncoder`/`IDecoder` interface is not disposable, which makes it difficult to use the interfaces with `using`. Only the implementations are derived from `IDisposable`
- Change: Moved the `IDisposable` interface from implementations to the IEncoder/IDecoder
- To fully support the use of the interfaces across the codebase new methods are added: `Close` and `CloseAndReturnAsText`
- Breaking change: In the `XmlEncoder` the `Close` method which returns an encoded string is renamed to  `CloseAndReturnAsText`
- Refactor codebase to use `using` with IEncoder/IDecoder across the board. Use interfaces where possible.
- To support streaming better with `ArraySegmentStream`, derive this class from `MemoryStream` and implement `ToArray`
2023-08-11 11:56:47 +02:00
Martin Regen 0a51dd3d02 Complete ISessionFactory interface (#2255)
- A few use cases were still missing from the ISessionFactory interface to make the static `Session.Create` functions completely obsolete. 
- Follow naming conventions (Async) and add CancellationToken where missing.
2023-08-10 16:41:36 +02:00
Martin Regen 1e535dda09 Support client activities on all target platforms (#2256)
- Add the system diagnostics library for unsupported target platforms
- Integrate in clientfixture by adding IDisposable to support to enable/disable the activity tracing
- fix Traceable session dispose issue, do not null the disposed session
2023-08-10 09:48:36 +02:00
Martin Regen 81340c3473 Support for session reconnect from distributed clients (#2244)
- Support Client.Session API to save and restore session configuration information as xml or in a serializable data structure.
- Support to reactivate a session using a new secure channel. 
- API tests
2023-08-03 22:27:53 +02:00
Martin Regen e61664f586 Truncate inner diagnostics if nested depth too high (#2247)
- `DiagnosticInfo` contains the `InnerDiagnosticInfo` which can be nested. Limit the recursion to `MaxInnerDepth` in multiple places to prevent stack overflow / endless loops.
- The default value for MaxInnerDepth should not be more than 5.
2023-07-31 16:11:40 +02:00
Martin Regen 1f17aad109 Better NodeId/ExpandedNodeId built in types handling (#2230)
- A NodeId string can be assigned to a NodeId and is automatically parsed. However, if the string contains a "nsu=" it is considered a string type NodeId instead of decoding the namespaceUri. To avoid this error in the code an `ArgumentException` is thrown to uncover these coding errors. Such a variable needs to be an ExpandedNodeId to be decoded correctly.
- Breaking change: To reduce coding errors the user group decided to throw also on a constructor call which does not contain a nodeid type prefix and namespace index. e.g. `new NodeId("Testnode")`. If somebody wants a string NodeId in Namespace 0 then call the constructor `new NodeId("TestNode", 0)`
- Implement IEquatable<NodeId>/IEquatable<ExpandedNodeId>
- Tests to ensure .Distinct treats all Null NodeIds as identical.
- Unit tests for constructor behavior.
2023-07-28 14:38:37 +02:00
Martin Regen 04cd9bc66a Zip embedded Opc.Ua.NodeSet2.xml to reduce assembly size (#2232)
- Add only the zipped NodeSet2.xml as embedded resource
- Reduces assembly size by at least 2MB
- Breaking Change: Embedded resource Opc.Ua.NodeSet2.xml is now Opc.Ua.NodeSet2.xml.zip
2023-07-27 19:06:26 +02:00
Martin Regen 9256c2e0fe Improve ArraySegmentStream hotpath (#2241)
- Improve the encoding/decoding hotpath in the `ArraySegmentStream` by adding override for ReadByte/WriteByte and enforce inlining.
2023-07-27 19:05:13 +02:00
Marc Schier 7f851599a2 Always use ArrayPool.Shared for optimized use of buffers in buffer manager (#2224)
* The suggestion from .net team is to use shared pool if you have < 1mb buffers you need. 
* We now share buffers across connections which is far more efficient when many channels are created and closed.
2023-07-22 18:45:54 +02:00
Martin Regen c64eb53509 Fix corner cases of subscription transfer (#2227)
- With the `sequentialPublishing` flag enabled, no data is received after transfer. Fix: add a resync flag to update the last sequence counter after transfer.
- Instead of the semaphore slim use a dedicated Task per subscription. The task  is using `AsyncAutoResetEvent` to be task friendly, becasue every subscription gets a worker task.
- Add more tests for the use case republish with delayed ack.
- Add a test and a missing method to support reconnect of a session on a different secure channel without reconnect handler.
2023-07-21 13:10:00 +02:00
Martin Regen 0bf2e93d8c Add IJsonEncoder/IJsonDecoder interfaces (#2042)
- in order to abstract the implementation of a IEncoder/IDecoder  for Json with some extra methods and properties, derive JsonEncoder/Jsondecoder from a IJsonDecoder/IJsonEncoder interface
- breaking change: the use of reversible/non-reversible subencoding is handled by a new method:
`void UsingReversibleEncoding<T>(Action<string, T> action, string fieldName, T value, bool useReversibleEncoding)`
2023-07-20 15:37:54 +02:00
Suciu Mircea Adrian eaa3cb0af5 Bring back Microsoft.Extensions.Logging.Abstractions to V3.1.32 for older target frameworks (#2229) 2023-07-20 10:47:49 +03:00
dependabot[bot] 5a08618af0 Bump Microsoft.Extensions.Logging.Abstractions from 3.1.32 to 7.0.1 (#2194)
* Bump Microsoft.Extensions.Logging.Abstractions from 3.1.32 to 7.0.1

Bumps [Microsoft.Extensions.Logging.Abstractions](https://github.com/dotnet/runtime) from 3.1.32 to 7.0.1.
- [Release notes](https://github.com/dotnet/runtime/releases)
- [Commits](https://github.com/dotnet/runtime/commits/v7.0.1)

---
updated-dependencies:
- dependency-name: Microsoft.Extensions.Logging.Abstractions
  dependency-type: direct:production
  update-type: version-update:semver-major
...

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

* Update Opc.Ua.Core.csproj

---------

Signed-off-by: dependabot[bot] <support@github.com>
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
Co-authored-by: Martin Regen <mregen@microsoft.com>
2023-07-19 10:33:07 +03:00
MarkusHorstmann 2738a2971c Support Dynamic Complex Types (#2146)
Complex Type support assumes that every OPC type is represented by exactly one .Net type, which in turn knows encoding ids, XML names etc.
These changes enable use of a single type that implements encoding/decoding based on OPC type information at runtime.
2023-07-16 09:50:18 +02:00
Martin Regen 17d4f0475f Fix stringtables for diagnostic results when service calls are batched (#2222)
- Issue fix: Currently when diagnostics is enabled in client calls, the string table in the response header is not updated when a service call is split into multiple service calls.  In this case the stringtables from all calls must be appended and the index in the diagnosticinfo must be updated to match the updated string list.
- To reduce the number of 'null' DiagnosticInfo allocations, the decoders now try to return null instead of a default DiagnosticInfo. A new property ÌsNullDiagnosticInfo' can be used to check for unused DiagnosticInfo entries.
- The tests were slightly improved to use test set data from the generated TestData namespace, which contains also a historical node.
- All `ServerFixtureUtils.ValidateXXX` checks were updated to include the check for diagnosticInfos and the string tables to catch issues.
2023-07-13 19:18:24 +02:00
Martin Regen cd38eca781 Various bugfixes for CTT and others (#2212)
- SessionClientBatched doesn't handle the case when diagnosticinfos are requested and the batched calls returns mixed empty or non empty diagnostic infos, then the returned infos did not match the number of requested items.
- write of arrays of analogItemState are not properly checked
- BuildInfo properties were empty because BuildInfoVariableValue is never initialized
- DataType and ReferenceType may return null attributes instead of BadAttributeIdInvalid.
- Add BuildInfo test and fix the NodeCacheTest
2023-07-04 16:44:06 +02:00
Martin Regen 49c85322bd Fix build on merged commits 2023-06-27 17:07:51 +02:00
Martin Regen ae00175fe8 Merge branch 'master' into master371_temp 2023-06-27 10:01:34 +02:00
Martin Regen 010a839ee8 Support custom cert store with flat directory structure (#2198)
In some use cases (e.g. Kubernetes secrets) it would be beneficial to store the certificates, private keys, crl etc. in a flat directory instead of having a root which contains a hierarchy with certs/crl/private etc. 
- Modify the `DirectoryCertificateStore` to allow it to use a flat structure by adding a special constructor.
- Add the configuration builder functions to allow to specify custom certificate stores for app/user/https.
- Add a test sample which shows how to use the 'flat store' with a custom cert store wrapper.
- By default, behavior of `DirectoryCertificateStore` is unchanged. Needs an external wrapper to expose the flat mode.
2023-06-22 16:31:21 +02:00
Suciu Mircea Adrian c81b6b0103 Added newly modified model compiler generated code for v1.04 (#2195)
Update the model compiler generated files with latest modifications which fix the embedded initializers of the generated classes.
2023-06-20 07:05:30 +03:00
Martin Regen e89b06e57b Add metadata to fast data and event callbacks notification. (#2176)
- if `DisableMonitoredItemCache` is set, the sequencenumber and publish time are unavailable. Add helpers to NotificationData to get the information in the fast data and event callbacks.
- new fast callback for keep alive messages
2023-06-14 09:47:21 +02:00
Martin Regen c7bd19dc46 Support use of opc.https endpoint url for client and server. (#2140)
Currently the https protocol doesn't support a spec compliant endpoint with a `opc.https` prefix., as client and server.
Fix:
- Add the client and server support for the `opc.https` prefix. 
- Continue support for `https` prefix for non compliant implementations.
- Any CancellationTokenSource should be disposed after being used.
- Follow coding guidelines
- Use macOS cert callback
2023-06-12 09:05:10 +02:00
Martin Regen 043a56c3f2 Deprecate .NET framework 4.6.2 support, sync with samples repo (#2165)
- Deprecate support for Nuget package support of .NET Framework 4.6.2
- Bump sample applications to 4.8
- update some copyright headers / supporting files (editorconfig etc.)
- fix a few warnings
- fix an issue with `SessionReconnectHandler`, in certain combination of reconnect period and exponential backoff the .NET sample app never reconnected.
2023-05-31 18:53:56 +02:00
Martin Regen d8f8a4e7ad Merge pull request #2163 from OPCFoundation/master371
Merge release 1.4.371.91 in master
2023-05-27 05:52:47 +02:00
Martin Regen 0a3546a3bf JsonDecoder: ReadExtensionObject returns partial JSON for some types (#2155)
Cherry pick bugfix from #2146:
ReadExtensionObject returns partial JSON for some types.
It appears that this is due to the JSON being read before the JsonTextWriter is closed.

see also: 2a4ba56

Co-authored-by: Markus Horstmann <markushorstmann@hotmail.com>
2023-05-19 15:20:53 +02:00
Martin Regen c13bb0e600 Fix possible memory leak of CancellationTokenSource (#2156)
Fix a few cases (not all) where TCS are not properly disposed. Specifically BeginConnect, which may cause resource leaks.
2023-05-19 15:19:04 +02:00
Suciu Mircea Adrian 24ba1d5db4 Allow initiation of reverse connections from all endpoints of the server. (#2152)
Currently only the first endpoint of the server will initiate a reverse connection, resulting in the possibility to connect only to it. This change enables connection to all the server's endpoints via reverse connect.
2023-05-19 08:41:56 +02:00
MarkusHorstmann 29a3be5533 Json Encoder: namespace URI handling (#2119)
Changes to the JSON Encoder to make it easier to deal with namespace URIs.
* #2117: JSON Encoder should provide option to encode NamespaceUri for all namespaces, including index 1
* #2118: JSON Encoder does not honor ForceNamespaceUri for QualifiedNames
2023-04-28 09:19:20 +02:00
Martin Regen 24845eb69d Use ICloneable in generated code (#2044)
- ICloneable was removed from generated code for the first port to .NET Standard 1.x, instead MemberwiseClone was used
- Reenable ICloneable for generated code
- Add ICloneable to built in types
- Fix code where MemberwiseClone is called instead of Clone
2023-04-27 11:08:13 +02:00
Suciu Mircea Adrian ae7f8e5120 OnServerStarting - Add null check on validationErrors (#2128) 2023-04-21 12:42:47 +03:00
Martin Regen 04721cb144 Return AdditionalInfo only to users with permission. (#2124)
- Add permission validation if client requests DiagnosticInfo.
2023-04-18 23:14:53 +02:00
Martin Regen abfbde3bec Improvements for docker hosting and fix for GetEndpoints (#2123)
- Add environment variables as parameter to support docker hosting where command line parameter are not available
- bump some Nuget packages
- only warn on cert validation error on startup, e.g. when the CRL becomes outdated allow to start and print warning.
- Let GetEndpoints return endpoints which match the DNS name used. DNS names must be specified as alternate hostnames in the configuration.
2023-04-18 18:09:55 +02:00
Martin Regen b5d4dd79cf Check DiscoveryOnly before the message is parsed. (#2112)
A discovery only channel only accepts discovery service calls. The type of service call should be checked before the message is parsed. 
- Add a check for discovery message before the chunks are decoded.
- Add a check that discovery service call are below a restricted message size (e.g. 64k).
- Add a test case.
2023-04-11 08:20:28 +02:00