22 Commits

Author SHA1 Message Date
romanett 7f037ef23e Enforce Valid Certificate Store configuration (#3023)
* fix Null Reference Exceptions on nonconfigured certificate stores

* try to fix gds tests

* Use explicit null check

* Validate Certificate Store configuration on startup in SecurityConfiguration.Validate.
Remove Obsolete CertificateStore Properties.

* remove unecessary fields

* fix tests

* fix client config

* Validate Stores by opening them

* fix typo

* check stores instead of storepath

* fix ClientTest

* Add Tests for Validate Mehtod of SecurityConfiguration

* Update ApplicationConfiguration xsd to respect stricter validation
2025-03-28 16:07:48 +02:00
Suciu Mircea Adrian 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 1c6253a729 AddRejected method for ICertificateStore (#2720)
- Add a light weight AddRejected certificate store method to `ICertificateStore` to ensure rejected cert history remains small and doesn't have a lot of overhead.
- Number of history certificates is configurable using a new `MaxRejectedCertificates` entry.
- Rejected certs are only saved to directory cert store, others do ignore the attempt
- Fix the caching of `CertificateValidator` and flag some `ÒpenStore` methods deprecated which do not support the caching. Fixes across the board to support the methodology. Basically `store.Close` keeps the cache, `store.Dispose` clears the cache, so recommendation is to use `var store = certStoreIdentifier.OpenStore(); try { ... }-- finally { store.Close }`
2024-09-03 15:23:32 +02:00
Martin Regen 7a04a4b396 Add UA Fuzzer solution for afl-fuzz and libfuzzer (#2603)
- Add a solution to provide fuzzer support for afl-fuzz and libfuzzer.
- Add fuzz targets for Binary, Json and Xml encoder and decoder fuzzing. For afl-fuzz and libfuzzer.
- Fix issues in encoders and decoders when unexpected exceptions are returned. The expectation is to return only ServiceResultException with BadDecodingError, BadEncodingError or BadEncodingLimitsExceeded.
- Add a tool to create Testcases. 
- Add a tool to playback crashes and timeouts.
- Solution is extensible with common files to discover new fuzz targets by reflection. New fuzz projects can share many files with the first project.
- Breaking change: Fix how BinaryDecoder is used: Previously, calling close on the BinaryDecoder implicitly disposed the stream. Change behavior so that `using` pattern can be applied across the board.
2024-05-02 22:29:29 +02:00
Suciu Mircea Adrian d1a9baa6c6 Added a limit to the Channels on the server side and removed "stale" channels (#2540)
* Added MaxChannelCount and detect and cleanup "stale" channels based on ChannelLifetime
* Add Environment.TickCount as time reference
* Set a socket backlog value to avoid socket open overflow
* Added a ChannelKeepAlive to signal when a session is still active
* Add options to console client to leak channels and run connect loop forever

Co-authored-by: Martin Regen <mregen@microsoft.com>
2024-04-22 13:28:19 +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 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 0236d082b1 Create client and server test projects, increase test coverage (#1434)
- Add Operation limit parameter and fix server. Fixes #1363 
- Add client/server test projects
- Add client and server fixture for test runs
- Server tests can test services without client connection
- Client tests can use common services to write tests which can run directly on server on via client server connection
- Increase code coverage > 50%
- Code coverage excludes the generated code
- Improve codecoverage local tests with report (see Tests/codecoverage scripts)
- Add a benchmark framework to client server tests
2021-07-06 18:01:54 +02:00
Martin Regen 838b99806d Reverse connect improvements for aggregation server (#1073)
- This improvement was tested with an aggregation server update on this branch:

Required for testing: https://github.com/mregen/UA-.NETStandard-Samples/tree/aggregationserver

Main changes: 
- Support holding of reverse connections, then a client can connect faster on a hold connection instead of waiting for the next reverse hello.
- Simplify API to connect with or without reverseconnect manager.
- Reconnect handlers code path added, tested with SessionReconnectHandler
- some locks on lists were not correctly implemented.
2020-08-13 12:50:17 +02:00
Alin Moldovean cf44debd5e ReverseConnectServer improvements (#1083)
* ReverseConnectServer improvements.
2020-08-07 10:48:28 +03:00
Martin Regen 46cd2d990a - Add the reverse connect in the reference server and a few bug fixes (#1071)
- Support the reverse connections in the reference server
- fix an issue when the anonymous token is sent as a null value by the aggregation server
- fix docker build files
2020-07-30 11:48:28 +02:00
Martin Regen 2e47eaa44f Support Reverse Connect in the stack with samples (#998)
- Ported from prototyping branch in .Net Legacy stack
- Client and server support
- Aggregation server sample
- .Net Core samples

more info in docs/ReverseConnect.md
2020-06-03 16:48:25 +02:00
Alin Moldovean 636f5c03f9 Implement validation for duplicate nonces (#893)
* - Add Server nonce validation for duplicate nonces.
- Add configuration flag to bypass validation exceptions

* Add ITransportChannel.CurrentToken interface for nonce validation.
2020-01-30 15:06:13 +02:00
AlinMoldovean f062bfdc89 Compliance fixes in CertificateValidator.
Added setting in SecurityConfiguration to require revocation lists for all CAs
2019-05-21 17:42:59 +03:00
AlinMoldovean 036320221b Create custom configuration settings and validators for user certificates. #383 2018-08-06 17:13:49 +03:00
AlinMoldovean 6ba20ba31a fix tabs in ApplicationConfiguration.xsd 2018-03-07 18:53:36 +02:00
AlinMoldovean 17dc14bcc5 Implement #362 - Certificate chain support. 2018-03-07 18:44:00 +02:00
Martin Regen 915ad5b87c - add cert configuration nodes
- Update cert and sign request is still missing
- no security!
2017-11-07 16:33:15 +01:00
Erich Barnstedt ef8fe340b6 1. Removed SecurityLevel from server config, it is now automatically calculated for each endpoint description.
2. Fixed spelling/grammar in a few places.
2017-05-08 12:29:57 +02:00
Erich Barnstedt e91b0ca400 1. Added OPC Publisher certs.
2. Fixed application extensions de-serialization.
2016-07-12 12:01:06 +02:00
Martin Regen 345d1b6655 rename cor to opc.ua.core to produce opc.ua.core assembly 2016-06-12 16:50:53 +02:00