Commit Graph

597 Commits

Author SHA1 Message Date
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
Martin Regen 8ddda78aff Fix for Usertokenpolicy Anonymous, security policy default should be None (#1756)
- Only an issue if the configuration does not specify the security policy uri for anonymous token
- If the config does not specify the security policy, for anonymous user token the security profile Basic256Sha256 was chosen. 
- This setting requires for the client to trust the server certificate if it tries to connect with security None, may cause IOP issues when no security is chosen and encryption is required for the anonymous user token.
2022-03-30 09:20:13 +02:00
Martin Regen 1263881a7f Adapt logging abstractions version to target framework (#1751)
* fix the nuget versions

* revert targetframework

* avoid build warning
2022-03-28 14:01:42 +03:00
Suciu Mircea Adrian 244234cdf0 Changes for testing and fixing git bug #1694 (#1747)
* Changes for testing and fixing git bug 1694

* Removed the duplicate server address differing by port number
2022-03-25 10:32:48 +02:00
Martin Regen 24931cfea0 fix SByte vs Byte collection (#1740) 2022-03-22 08:29:31 +02:00
Martin Regen cfc68eeb10 Use .NET analyzers instead of Roslynator, fix warnings, no bug fixes (#1729)
-use latests analyzers in .NET instead of Roslynator.
-fix warnings and formatting, no bug fixes!
2022-03-14 16:39:09 +01:00
dependabot[bot] 2a74b44627 Bump Microsoft.Extensions.Logging.Abstractions from 6.0.0 to 6.0.1 (#1728)
Bumps [Microsoft.Extensions.Logging.Abstractions](https://github.com/dotnet/runtime) from 6.0.0 to 6.0.1.
- [Release notes](https://github.com/dotnet/runtime/releases)
- [Commits](https://github.com/dotnet/runtime/compare/v6.0.0...v6.0.1)

---
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>

Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
2022-03-09 19:40:18 +01:00
ThomasNehring 3dc1d4beba Update BuiltInTests.cs with special case compare Null NodeId (#1609)
A  new unit test which will currently fail, due to incorrect treatment of node ids with numeric identifier 0 in the namespace with index 0. ( "NodeId nodeId = new NodeId (0,0)." ).

Of course such a node id is invalid. It seems to be present, however, in some PLCs under certain situations. We encountered such node ids in the context of a customer ticket. The node ids were read into instance of type "DataValue" using the read service call. The evaluation of the read result then failed due to comparisons like the ones in the unit test.

fixes #1610
2022-02-18 16:53:50 +01:00
Martin Regen efd04655a6 Bug fix for server registration issue (#1713)
-always use a clone of the configuration and replace cert validator when registration is active.
-fixes #1711
2022-02-18 08:30:40 +01:00
Martin Regen 7d9be41cf5 Doc updates and fixes for .368 preview, ref server improvements (#1695)
- Doc, docs, docs updates for new 368 support
- fix a missing null pointer check when ConditionRefresh is run
- Ref server: move NodeManager factory API to StandardServer, decoupling the NodeManager implementation from Ref server
- Ref server: add shadow mode flag, to allow to map a docker configuration in a mapped folder.
- Ref server: sample batch files how to run Github CR and local docker images
- Improve some misleading 'delete application certificate' log messages.
2022-02-11 09:19:40 +01:00
dependabot[bot] a7b561158b Bump System.Io.Pipelines from 6.0.1 to 6.0.2 (#1703)
* Bump System.Io.Pipelines from 6.0.1 to 6.0.2
* Fix the fast PR build

Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
Co-authored-by: Martin Regen <mregen@microsoft.com>
2022-02-10 19:01:41 +01:00
Martin Regen 5d9234eebe Handle subscription transfer special cases + tests (#1700)
- Fixed issue: After transfer, available sequence numbers were not properly ack/republished.
- Fixed issue: After transfer, race condition could delete subscription before transfer finished.
- Fixed issue: After reload of a subscription, duplicate client handles may have been used.
- Add tests which emulate the disconnection of a client/server, then transfers
- Add subscription variable to select if missing publish requests are just acknoledged (default) or republished after transfer completes. Set `Subscription.RepublishAfterTransfer` to `true`.
- Improve test framework to allow for testing against external servers using a .runsettings file
- improve publish request logging, by moving calls into `CoreClientUtils.EventLog`
- disable available sequence numbers check, it causes false negatives when many subscriptions are active
2022-02-07 17:37:01 +01:00
Martin Regen 8c1a659ecf Reference Server updates running CTT (#1689)
- Provide the CTT configuration used for 1.4.9.398: Added tests with arrays except Variant
- Match the Reference server config for CTT run (Console Server was used, others tbd)
- add a few cases in ref server node manager to enable skipped tests
- preset random generators to create deterministic node data 
CTT fixes:
- Trigger: fix a regression introduced with the TransferSubscription support, Trigger stopped working, revert change to remove LinkedList in MonitoredItems
- return BadDataEncodingUnsupported creating MonitoredItems
- ensure that MonitoredItem node data reported as required by CTT after initial reading, transfer and SetMonitoring

note: not yet 100% passy, a few uncritical failing tests are still under investigation

Co-authored-by: mrsuciu <Mircea-Adrian.Suciu@softing.com>
2022-01-31 13:32:58 +01:00
Suciu Mircea Adrian 5025648cbc GetEndpoints: Eliminate duplicate endpoints when Configured base addresses differ by port only (#1687)
- use case: specify the same endpoint protocol with two ports. The returned array  contains too many entries, because now the policyId in the UserTokenpolicies was fixed and no more duplicates were detected.
2022-01-29 14:47:05 +01:00
Martin Regen 430ff70de7 Implement Transfersubscription service (#1649)
- Implement client and server side of Transfersubscription service calls.
- New Transcription service has been tested with CTT 1.04.9.398
- Unit tests for native service calls and client SDK
- Client implements multiple ways to transfer sessions:
  - Client saves subscriptions to xml stream, restarts, loads subscriptions from stream and transfers on server.
  - Client creates a new sessions and transfers into new session, while the old session is still active.
  - Client closes old session with `DeleteSubscriptionsOnClose = false`, creates new session and transfers subscriptions to new session.
  - `SessionReconnectHandler` tries to transfer subscription before recreating the subscriptions.
- breaking change: INodeManager got a new TransferMonitoredItems method

Co-authored-by: Alexander Koepke <alexander.koepke@microsoft.com>
Co-authored-by: Peter Bryntesson <pbrynt@microsoft.com>
2022-01-28 13:21:20 +01:00
Martin Regen 079148f3ab ctt fixes (#1685)
* remove the SetDurableSubscription method, to skip the test cases
* DeleteSubscription returns BadSubscriptionIdInvalid
* MethodState return also BadTooManyArguments
* return AttributeIdInvalid for null attributes (fix UA Expert display)
* fix ToString of Variant array of ByteString
* fix Variant decoding 1-dim array of bytestring
2022-01-27 09:46:32 +02:00
Archie Miller 5d33c16188 Implement a common method for creating branches (#1603)
Implement a mechanism to create Alarm Branches, store them, allow AddComment, Acknowledge, and Confirm them.

Updates the Retain flag automatically.
Cleans up branches on Ack/Confirm

Allows servers to retrieve branches to clear them all if necessary.
2022-01-25 07:46:21 +01:00
Martin Regen 5cbffcfe77 Support async ICertificateStore CRL interface methods (#1666)
- integrate 'LoadPrivateKey' in the interface to allow to implement cert stores which require a passcode to load/store certificates
Change of behavior:
- Introduce a 'NoPrivateKeys' flag to reduce the risk of leaking a private key to a unsecure store.
  - CertificateStoreIdentifier opens 'NoPrivateKey' stores
  - CertificateTrustList opens 'NoPrivateKey' stores
  - CertificateIdentifier opens store with private keys for application or GDS authority certificates
- CertificateTrustList reuses a store if it is not disposed. A user can just close the store to keep the list of certificates in memory.
- DirectoryStore `Load` does not read private keys anymore, only file names for delete. Reading all private keys caused false errors, e.g. here: #1670 

Co-authored-by: mheege-abb <marcus.heege@de.abb.com>
Co-authored-by: mheege-abb <85437567+mheege-abb@users.noreply.github.com>
2022-01-25 07:16:28 +01:00
Martin Regen 3fe949559d Retry to load private key of a new certificate on import error. (#1676)
- In windows container this non deterministic error can occur:
`[WindowsCryptographicException] The specified network password is not correct.`
even if the private key was saved with empty password.
- Fix: After a delayed retry the private key can be loaded successfully.
- fixes #1670 
- see also https://github.com/OPCFoundation/UA-.NETStandard/commit/ae9ecac2be6b2f9ed6c639eb60205896c27791e0 for 367 milestone
2022-01-24 17:05:34 +01:00
Suciu Mircea Adrian 33ae73654c Improve initalization of BaseVariableState (#1672) 2022-01-20 06:50:48 +02:00
Suciu Mircea Adrian 213f37e28b Set the default value of the StatusCode on BaseVariableState to BadWaitingForInitialData. (#1668)
* Removed assigning a default value to any variable value in the AddReverseReferences method.
Set the default value of the StatusCode on BaseVariableState to BadWaitingForInitialData.

* Allow initalization from variable states with status code BadWaitingForInitialData
2022-01-19 09:25:27 +02:00
mheege-abb 61e204f1d9 Add support for custom certificate stores (#1420)
The current SDK supports only Windows and Directory certificate stores. For security reasons, it can be necessary to use custom certificate stores. 
* Add support for custom certificate stores
* Certificate Store Type UnitTests
* Start cleanup of ICertificateStore interface in the CRL section (Co-authored-by: Martin Regen <mregen@microsoft.com>)
2022-01-17 15:13:59 +01:00
ThomasNehring dd6f4a4c8d Updates for getIssuer(s) in the Certificate Validator class (#1632)
- Adapted getIssuer and getIssuers so that all findings get aggregated for later processing in the validation methods.
- Ensured that other methods calling getIssuer(s) will experience unchanged behavior
- Adapted unit tests
2022-01-14 16:11:31 +01:00