Commit Graph

619 Commits

Author SHA1 Message Date
Martin Regen 25ef63388f merge release 2022-11-20 08:26:19 +01:00
Martin Regen e9cedca4d5 On discovery preserve IPv6 scopeid for local link addresses (#1976)
Using the uri.OriginalString instead of the 'ToString()' preserves a scope id of a IPv6 local link address.
2022-11-16 08:55:07 +01:00
Martin Regen f962e3e93a Fix cloning of NodeState derived classes, add latest Modelcompiler support (#1990)
Implement `MemberwiseClone` in some derived NodeState base classes and use `IClonable` to create a clone to preserve the class information. 

Note: a deep copy requires a call to initialize after clone.

- the latest modelcompiler supports Nodeset2 which may not include the definitions for XmlencodingId or JsonEncodeingId, based on the design file.
-Catch NotSupportedException in the encodeableFactory to ignore a unsupported XmlEncodeingId. 
-use IJSONEncodeable to create JSON encoding Id, if supported. Otherwise use reflection to create the id.
- Support `IClonable` in `Utils.Clone` for code which is not aware.
2022-11-16 08:51:09 +01:00
Martin Regen e22bd868e5 async calls are not awaited, simplify the write to rejected store (#1992)
- Missing await on async call to write cert to rejected store. Found with analyzer `Microsoft.VisualStudio.Threading.Analyzers`
- Simplify the write by not deleting certificate with the same thumbprint, just override.
- Accidently writing a private key is not possible anymore, the cert stores are now flagged with noprivatekey support. Remove special handling.
2022-11-15 09:15:27 +01:00
Martin Regen e100554020 Ua 1.04.11 updates for ua 1.05.02 final (#1984)
Update 1.04.11 Nodeset with output from latest ModelCompiler with 1.05.02 support.

Co-authored-by: Randy Armstrong <randy@sparhawksoftware.com>
2022-11-08 17:44:56 +01:00
Martin Regen 7cc8479f61 Recover binary decoder from decoding error of custom complex type (#1974)
on a decoding error of an ExtensionObject (custom complex type), the binary decoder resets the read pointer in the stream and decodes the object as ByteArray assuming the underlying complex type interpretation is invalid.
With this method decoding of large chunks can still succeed, see #1705.
The root cause for this issue is currently that client and server may have IOP issues on how structured complex types are encoded. Such warnings must be investigated and fixed.
2022-11-07 11:54:48 +01:00
Martin Regen 54b2b643b3 Update with Modelcompiler UA 1.05.02 2022 11 01 (#1970)
* Add 1.05.02 generated files.

Co-authored-by: Randy Armstrong <randy@sparhawksoftware.com>
2022-11-01 18:55:47 +01:00
Suciu Mircea Adrian 8c7da18657 Refactor the handling of matrix dimensions. (#1927)
- Move Matrix class to Matrix.cs 
- refactor helper to catch invalid dimension in a single function
- More tests
2022-10-24 14:24:30 +02:00
opcfoundation-org c070f0b421 Ua 1.04.11 update for 1.05.02 (#1955)
-Minor documentation fixes to be merged.
-Add IJsonEncodeable support.
Co-authored-by: Randy Armstrong <randy@sparhawksoftware.com>
2022-10-24 14:10:54 +02:00
Martin Regen a3408e71f6 Fix .NET7 build (#1952)
.NET7 introduces a X509AuthorityKeyIdentifierExtension datatype which causes some ambigous datatype build errors.
Tested on .NET7 rc2

Note: Targetframework as .NET7 has not been added yet. Fix just the build if somebody tries.
2022-10-24 10:17:17 +02:00
opcfoundation-org 226b0ceb66 Update 1.04.11 generated files with 1.05.02 Modelcompiler update. (#1954)
-Modelcompiler Update 1.04.11 generated files.
-Update of UANodeset.xsd with 1.05.02 version.
-Add generated templates for ISessionClientMethods 

Co-authored-by: Randy Armstrong <randy@sparhawksoftware.com>
2022-10-17 11:55:20 +02:00
Martin Regen da1b1a7112 Add Session.CloseAsync, fix UANodesetHelper.Save (#1944)
-Add Session.CloseAsync methods.
-Add missing Close signatures to ISession
-Mark the CloseSession service call as obsolete to prevent invalid usage
-fix UANodeSetHelper.Save(stream), to not close the stream
-fix a deadlock in the ref server app, due to the new default behavior of the cert validator not caching the approved certificates
2022-10-11 11:03:00 +02:00
Ivan van Heerden 1f2a30d7ca Add abstraction 'ISession' for Session object in the Client library (#1702)
Expose an 'ISession' interface as abstraction to ease unit testing. 

Breaking changes are kept to minimal impact, but some changes maybe required to use ISession objects instead of Session.

Note: ISessionClientMethods is hand created, not yet by ModelCompiler
2022-10-07 20:11:53 +02:00
Martin Regen 77b89500f9 Use of validated certificates needs opt-in. (#1925)
Currently, the validated certificates are stored in a dictionary for fast compare of the certificate validation when an application reconnects, until manually cleared by e.g. `ResetValidatedCertificates()`. After discussion it was decided to make this function an opt-in feature to avoid use cases where changes in the trusted store or CRL are not reflected in the list of validated certificates.
The runtime penalty of a full check can be avoided if needed with the 'Opt-In' by configuration or by application setting the property. After opt-in it is the application responsibility to clear the list of validated certificates if needed.

+++ Other cert validator improvements/fixes

- Setting the `ValidationOptions.SuppressRevocationStatusUnknown` on a trustlist (e.g. issuer) was ignored
- If another client/server connects with a chain, the whole chain is saved to the rejected store, not only the leaf certificate.
2022-10-06 10:53:32 +02:00
Martin Regen 1fec89b073 Complex types improvements (#1915)
Improvements for complex types.

- Support to encode/decode complex type structures with multidimensional arrays.
- Perf improvements for type loader using new NodeCache fetch multiple interfaces.
- DataTypeDictionary validation when dependencies are used.
- interface for complex type resolver, to build custom types in code.
- improvements of console client to demonstrate browse/read of custom values

+++ Breaking changes +++

IDecoder interface change of the `ReadArray` method

- Return type is now `Array` for all types of arrays. Previously the method returned an array for 1-dim and a `Matrix` type for multidimensional arrays. In addition the convention in generated code is to use `Collection` for all 1-dim arrays, and so was built the `BaseComplexType`. The new convention is to expose the native `Array` type from a complex type, in all cases, hence the return type of `ReadArray` was changed to reflect that for a consistent programming model.
- `ReadArray` has a new parameter `systemType` to efficiently read encodeable types. Previously the `Type` of an encodeable was determined by the encodingid and lookup in the type factory, even when the Type is already known by the caller.  The 'old' style is still supported.
- `ReadArray` supports to read encodeable type arrays which are directly encoded in structures. These arrays differ from standard encoding of arrays and they are handled when `BuiltInType.Null` is used as parameter.
2022-10-04 19:45:26 +02:00
dependabot[bot] 95c384f454 Bump Microsoft.Extensions.Logging.Abstractions from 6.0.1 to 6.0.2 (#1932)
* Bump Microsoft.Extensions.Logging.Abstractions from 6.0.1 to 6.0.2

Bumps [Microsoft.Extensions.Logging.Abstractions](https://github.com/dotnet/runtime) from 6.0.1 to 6.0.2.
- [Release notes](https://github.com/dotnet/runtime/releases)
- [Commits](https://github.com/dotnet/runtime/compare/v6.0.1...v6.0.2)

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

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

* Update Opc.Ua.Core.csproj

* Update UA Client Controls.csproj

* Update UA Server Controls.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>
2022-09-26 10:41:18 +03:00
Martin Regen 885c7b2d2c Fix server url mismatch handling (#1914)
* change the Certificate domain validation to work also for the server case
* do not refuse a connection if the check fails, only trigger the audit event
* bump up test Nuget
2022-08-30 22:18:15 +02:00
Martin Regen d0fb11dddd Set higher default client chunk count limit (#1916)
-Issue: A server might return a much smaller send and receive buffer size than what was proposed in the hello message by a client. Given the current default max chunk count, which is based on the default buffer size, the response message size is also limited by the calculated max chunk count.
- fix: Calculate the default max chunk counts based on the TCP client min buffer size.
2022-08-22 13:52:21 +02:00
Martin Regen f273634d74 Improve https transport and other bug fixes (#1908)
-Make the https callbacks fully async / code cleanup. 
-Default https client to use MaxConnectionsToServer = 64 for #1550
-Fix https missing reconnect error code
other fixes unrelated to https:
- move trust list audit event to AuditEvents.cs, fix issue that the event is not filtered since reportAuditEvent cannot be used
- fix an issue when BrowseNext for multiple continuation tokens doesn't add the results array properly
- bump up .NET Core 3.1 Nuget dependencies
- improve .NET reference client app for use with https
2022-08-20 23:44:09 +02:00
opcfoundation-org 346e7a61f9 JSON objects cannot have the DataTypeEncodingId (#1911)
*The EncodableFactory does not index the JSON DataTypeEncodingIds because they are not defined on the types.
As a result, a JSON document that complies with the specification (see https://reference.opcfoundation.org/Core/Part6/5.4.2/#5.4.2.16) cannot be parsed.

* This change creates the JSON encoding types ids from generated code using reflection, so the JSON documents which comply with the spec can be decoded.

* Fixes type id on a JSON encoded ExtensionObject that contains binary or xml encoded data.

Co-authored-by: Randy Armstrong <randy@sparhawksoftware.com>
2022-08-18 16:49:24 +02:00
Martin Regen 0ad5c4c3a3 Refactor audit events (#1895)
- Move the auditing flag to server internal
- Hook up new configuration setting to the Auditing node
- A Security Admin can change the Audit setting.
- Refactor audit events to be extensions in one class.
- enable auditing and diagnostics by default for higher test coverage.
- refactor dependency of some events to bindings, e.g. TcpServerChannel should not be used as reportevent parameter
2022-08-12 20:04:02 +02:00
Martin Regen dd78c0be93 Client perf updates for NodeCache and service call layer to batch Operation Limits. (#1876)
- Add methods to support to Read/Browse multiple nodes in session and NodeCache.
- Add methods to find references of multiple nodes in NodeCache.
- By default the client fetches the operation limits from the server.
- Add operation limit object to client config, settings are overwritten by server limits if server limits are smaller.
- Split client service calls if operation limits are exceeded with an override of the SessionClient. All sync/async service calls are implemented, but not the servcie calls using the Begin/End pattern.
2022-08-08 11:43:55 +02:00
Martin Regen 5a77423265 Update codeql action script to v2 (#1894)
* bump up abstraction logging 3.1.27, add references to solve some warnings
2022-08-08 05:38:24 +02:00
Suciu Mircea Adrian 9b05714fa8 Handle processing matrixes with array dimensions that overflow. (#1891) 2022-08-07 18:44:59 +03:00
Suciu Mircea Adrian 274dfaddba Implementation of audit event triggers (#1867)
* Implementation of audit event triggers
2022-07-17 18:41:43 +03:00
Vincenzo Carlino cf0c878283 Add methods for reading multiple nodes (#1522)
* Add new methods for reading a set of nodes
* ReadNodes(NodeIdCollection, out DataValueCollection, out IList<ServiceResult>, bool optionalAttributes)
* (DataValueCollection, IList<ServiceResult>) ReadNodesAsync (NodeIdCollection, bool optionalAttributes)
to reduce the amount of attributes read from a server ReadNodes first reads only the NodeClass, then reads only the mandatory attributes per nodeclass to reduce the overall number of attributes to read.
If the NodeClass of all nodes is already known, the read can be further optimized to read only the attributes for a known class:
* ReadNodes(NodeIdCollection, NodeClass, out DataValueCollection, out IList<ServiceResult>, bool optionalAttributes)
* (DataValueCollection, IList<ServiceResult>) ReadNodesAsync (NodeIdCollection, NodeClass, bool optionalAttributes)
to complete async and collection operation, there is a:
* ReadNodeAsync and 
* ReadValues/ReadValuesAsync

* An issue was fixed in the https async codepath, the security header was not properly set in async operation

sidenote: operation limits must be handled by caller!

Co-authored-by: Martin Regen <mregen@microsoft.com>
2022-07-17 06:19:11 +02:00
Zigby 559c382666 Fix Server JWT Token Support (#1817)
* Handle JWT and set the IssuedTokenType in the server based on the policy referenced by the PolicyId in the client supplied UserIdentityToken .
* Connect/Reconnect tests cases with JWT
2022-06-30 14:02:07 +02:00
opcfoundation-org df71776c75 Modelcompiler 1.04.11 (#1850)
* latest nodeset without reference to servicemodel
2022-06-21 11:51:41 +03:00
Martin Regen 93e549ad4b Hide error message for BadSecurityChecksFailed (#1846) 2022-06-10 13:49:29 +02:00
Martin Regen 6d675b8cd0 Use secure passcode for temp pfx (#1838)
- instead of random guid use a passcode generated with CPRNG.
2022-06-07 11:53:50 +02:00
Suciu Mircea Adrian 57f979b559 InstanceStateSnapshot sets value of Handle when Initialize is called to "state" argument
InstanceStateSnapshot sets value of Handle when Initialize is called to "state" argument.
2022-06-06 14:25:53 +03:00
OctaviaStan 8cc18b32fc The formatter implementation from Microsoft.Extensions.Logging.LoggerExtensions class is ignoring the exception object and the exception information is not saved into log file. see the existing implemetation from below. (#1827)
Added handling for situation when the exception is not null and reused the existing code for formatting exceptions.
2022-05-31 08:31:06 +03:00
niveditha-sooda 0ac410b8b1 Loader for PEM private keys, Custom cert validator application error message (#1765)
-Added a loader if no PFX private key exists, the PEM private key is loaded.
-Added the support in certificate validator for custom application error messages.
2022-05-28 09:37:31 +02:00
Jörn Schlingensiepen a7cfe2f2b7 Update NodeID sample comment (#1820)
The sample included a fully named NodeId but the Format() uses the information already included in the instance. It might be easier to understand, if there is another sample and a node. Thus we can avoid confusion.
2022-05-13 13:32:28 +02:00
Martin Regen f345f909b6 merge master 2022-05-13 07:56:31 +02:00
Martin Regen 88a96a1d97 Handle special cases for chunking. (#1816)
- Chunk count one compare is incorrect
- Instead of a static configuration calculate the chunk count limits dynamically, as changing buffer size in the negotiation was not taken into account and could lead to reduced message size.
- Remove the static chunk count calculation.
2022-05-12 20:45:25 +02:00
Martin Regen fd9a91afe7 Fix issues with reconnect handler and subscription transfer (#1802)
- set `KeepAliveTimeout` default back to 5s, was unintentionally set to 50s in 368 release
- fix a bug that duplicate subscriptions were created after reconnect when transfer succeeds.
- add a property to enable subscription transfer in reconnect, set `Session.TransferSubscriptionsOnReconnect=true` to enable, IOP issues may not allow to use it with some servers.
- add a `SessionReconnectHandler(true)` constructor to support reconnect abort, if the connection recovers before reconnect timer called. If the new constructor is used, its a breaking change: Needs check of  `Session` property in Reconnect handler callback, if aborted `Session==null`.
- Reduce warning log output if server timestamp > client time.
- Add handling when subscriptions can not be transferred, e.g. when false user credentials or no security prevent transfer.
- Improve the reconnect timer handling by using `OperationLimit` in reconnect.
- Add sample for `SessionReconnectHandler` in console client.
- Seperate session sample code from `UAClient`.
- Tested on popular demo servers of various SDK vendors.
- Fix Winforms ref client
2022-05-11 22:28:07 +02:00
dependabot[bot] a7d5865e06 Bump System.Io.Pipelines from 6.0.2 to 6.0.3 (#1806)
Bumps [System.Io.Pipelines](https://github.com/dotnet/runtime) from 6.0.2 to 6.0.3.
2022-05-11 16:56:06 +03:00
Suciu Mircea Adrian 71af2c1d15 Added default value DefaultMaxChunkCount (#1789)
* Added default values DefaultRequestMaxChunkCount and DefaultResponseMaxChunkCount
* The negotiated Request and Response MaxChunkCount values are checked when building a chunked message.
2022-05-07 20:54:09 -07:00
Suciu Mircea Adrian 1e22c4d83f Filter events against Role-based permissions (#1798)
Events can be filtered against the Role-based permissions.
2022-05-06 09:30:43 -07:00
Martin Regen 51549f5ed8 Strict rules to compare X500 distinguished names (#1784)
- Certificates should compare X500DistinguishedName with binary ASN.1 compare
- Other compares should follow ordinal and not resort DN entries
- Fix all related issues to pass tests, e.g. GDS certificates accepted with reversed Subject, cert validation
- Add defensive checks in cert validation 

Co-authored-by: mrsuciu <Mircea-Adrian.Suciu@softing.com>
2022-05-06 16:11:34 +02:00
Suciu Mircea Adrian ae9bf1beef Check op limits on Variant arrays and TranslateBrowsePathsToNodeIds (#1788) 2022-05-05 11:40:19 -07:00
KircMax 5722dd56f7 Add property to get local endpoint from IMessageSocket (#1793)
Add the getter (since the System.Net.Sockets.Socket: m_socket does not implement a setter) for the LocalEndPoint so that a user can access the Information on which IP+Port the Socket is running on
2022-05-05 11:33:44 -07:00
Martin Regen 7072fe0771 Improve ref server for use with CTT (#1775)
- Improve formatting and log strings for new alarm node managers.
- Remove the TestData Alarms as they cause issues in the CTT tests
- Add a -ctt option to start the alarms endless for testing, stop alarms in other node managers.
- Unify the way the node managers are created in the quickstarts sample.
- Bring back 'dummy' appveyor config to disable the builds.
- fix codecov build
- add a few more unrelated tests
2022-04-19 09:29:21 +02:00
Martin Regen 73533cc17f Add missing EC PEM Export, refactor test asset enumerator for generalized usage (#1774)
- Add missing PEM private key export for EC (.NET6/Netstandard2.1 only)
- Remove some duplicate code in PEMWriter class
- Refactor enumerator for Test Datapoint sources to be generic and usable for more cases
- Add some tests for NodeSet2 import (using the refactored enumerator)
- Fix some warnings and PR template typos along the way.
2022-04-11 17:53:31 +02:00
Suciu Mircea Adrian 3f04e9d370 Filter out audit events in case the ServerType_Auditing values is false or the channel is not encrypted (#1770)
* Filter out audit events in case the ServerType_Auditing values is false or the channel is not encrypted
2022-04-08 10:41:28 +03:00
niveditha-sooda fa523b905a Changed the access modifiers for a few client session members (#1737)
-change to the access modifiers for some of the members in the Session class and a method in the DataDictionary class to support custom solution.
2022-04-01 15:32:59 +02:00
Zigby cbe886dcb0 Enable client support for multiple sessions on a single channel (#1659)
* Client API changes to support multiple sessions on a single channel
* Tested against freeopcua:python:server and ProSys simulation server
2022-04-01 14:27:32 +02:00
Martin Regen eda38cb6c2 XmlSerializer in .NET 6 Omits Line Breaks by Default (#1760)
* fix xml output in .NET 6
* unify the way xml writer settings are generated and used, add validation tests
2022-03-31 20:13:49 +02:00
Martin Regen 3a378e8644 Fix dual license headers (#1763)
Headers incorrectly state that the RCL applies to members, however the OPC Source Deliverables license states RCL is applicable only to corporate members. 

The OPC Foundation Technical Control Board on March 30th decided on the following changes with regard of the license headers:

• Change the dual license in the source files so that “members” are replaced with “corporate members”. 

Co-authored-by: Suciu Mircea Adrian <Mircea-Adrian.Suciu@softing.com>
2022-03-31 13:14:17 +02:00