1
0
mirror of https://github.com/FreeOpcUa/opcua-asyncio synced 2025-10-29 17:07:18 +08:00

2372 Commits

Author SHA1 Message Date
Olivier
d8a5de3fe4 new release v1.1.8 v1.1.8 2025-09-05 20:21:56 +02:00
Olivier
fe795e16ad fix release script 2025-09-05 20:21:47 +02:00
Mattis Voss
cacd6a0c35 Replace time.time() with time.monotonic() in asyncua core modules
The library currently uses time.time() for timing in multiple places,
which causes problems when the system clock changes (e.g. manual adjustments).

time.monotonic() offers a monotonic clock unaffected by system time changes,
making it more reliable for measuring time intervals and timeouts.

This commit updates all occurrences of time.time() to time.monotonic() in:

- asyncua/crypto/security_policies.py
- asyncua/server/internal_subscription.py
- asyncua/server/uaprocessor.py
- asyncua/client/ha/reconciliator.py

Addresses issues reported in https://github.com/FreeOpcUa/opcua-asyncio/issues/1848.

Tested with existing test suite. Two tests fail on master as well, unrelated to this change.
v1.1.7 v{v}
2025-08-02 09:52:12 +02:00
Olivier
b3dd3a17ff make pytest loop scope explicit 2025-07-23 16:24:34 +02:00
Olivier
a5d72a2dc2 finally unfreeze pytest-asyncio 2025-07-23 16:24:34 +02:00
Christian Granzin
cc874c30e2 Feat: Support import/export of struct and enum Field descriptions (#1851)
* parse struct and enum field descriptions when importing

* export struct and enum field descriptions

* rename
2025-07-20 15:27:55 +02:00
thegart
97095b909c Support pre 1.04 struct length fields for B&R 2025-05-05 11:57:51 +02:00
oroulet
5b1091795d fix connecting to new prosys opcua server (#1827)
* make prosys accept our certificate again in examples

* allow to send certificate without encryption or user identification as prosys now requires.
Had to fix a few new bugs that sudently appeared...

* clean imports

* remove leftover prints, less verbose when renaming struct

* remove unused variable

---------

Co-authored-by: Olivier <olivier@helitech>
2025-04-29 15:55:27 +02:00
Lukas Kaupp
120d2e8c09 Fix small bug if imported xml has also the stardard namespace included (#1832)
* fix xml issue if standard namespace is also exported in the xml export file.

* ruff reformatted

* added safe guard

---------

Co-authored-by: Lukas Kaupp <lukas.kaupp@h-da.de>
2025-04-28 14:32:17 +02:00
Lukas Kaupp
d52d319b7c Enhancement: Chunked Build ETree Function (#1833)
* Added a chunked version of build etree to prevent a server-overload because of the mass of subsequent requests.

* Added a chunked version of build etree to prevent a server-overload because of the mass of subsequent requests.
Added argument description
Extended the _add_namespace method

* ruff reformatted

---------

Co-authored-by: Lukas Kaupp <lukas.kaupp@h-da.de>
2025-04-28 14:31:53 +02:00
Christian Granzin
6b6f4bb220 Fix: Issues with missing namespace URIs when importing and exporting XMLs (#1830)
* fix dependent namespace handling for importing and exporting xmls and add tests

* fix other test cases
2025-04-28 12:38:07 +02:00
Florian Dörsch
f12f3e19b3 fix ClientNonce and/or peer_certificate may be None
The ClientNonce and also the peer_certificate can be set to None,
this fixes the resulting TypeError

```
Traceback (most recent call last):
  File "...\Python312-32\Lib\site-packages\asyncua\server\uaprocessor.py", line 147, in process_message
    return await self._process_message(typeid, requesthdr, seqhdr, body)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "...\Python312-32\Lib\site-packages\asyncua\server\uaprocessor.py", line 213, in _process_message
    data = self._connection.security_policy.peer_certificate + params.ClientNonce
           ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~^~~~~~~~~~~~~~~~~~~~
TypeError: can't concat NoneType to bytes
       ^^^^^^^^^^^^^^^^^^^^^^^
TypeError: object of type 'NoneType' has no len()
```

fixes #1821
2025-04-25 08:57:54 +02:00
Ryan Mickler
e3e02e3cfa Include support for x509 certificate chains in DER format (#1822)
* Fix certificate chain handling in x509_from_der function

This change enhances the x509_from_der function to properly handle certificate chains
by extracting and using the first certificate when a chain is detected.

When a certificate chain is received, the cryptography library raises a ValueError
with 'extradata' in the error message. This fix catches that specific error and
implements DER parsing to extract the first certificate from the chain.

This allows the library to work with certificate chains that some OPC UA servers
might provide, improving compatibility.

Fixes #1148 and #1245

* Update CHANGELOG.md with certificate chain fix

* Improve exception handling comment in x509_from_der function

* Add tests for certificate chain handling

* Fix code formatting issues

* Apply Ruff formatting changes

* Remove unused os import from test file
2025-04-19 11:13:51 +02:00
Olivier
4a11975af7 fix release script 2025-04-08 14:51:23 +02:00
Olivier
7e7c62648b v1.1.6 2025-04-08 14:51:23 +02:00
Christoph Ziebuhr
cde0e3b10d SenderCertificate shall be null if the Message is not signed 2025-04-08 12:51:35 +02:00
Sandor
c266a89b8c Update uatypes.py
Typo in the LocalizedText()'s comments. And some unresolved references in docstrings.
2025-04-08 12:50:40 +02:00
Olof Ohlsson Sax
01dba1ced8 Avoid logging non-exceptional exception, and fix error in log format string
If loading data types out of order it is expected to get an exception in load_data_typ_definitions. We shouldn't report this to the log file until we give up on loading types.

This also fixes an error in the log format string, which leads to an exception when logging.
2025-04-08 11:45:04 +02:00
Sandor
5909d86e57 Aware time in the examples (#1802)
* datetime.datetime.utcnow() is deprecated and scheduled for removal in a future version. Use timezone-aware objects to represent datetimes in UTC: datetime.datetime.now(datetime.UTC).

So I use ".now(UTC)"" and "from datetime import datetime, UTC". And fix typos. Optimize imports

* I accidentally deleted a line.
2025-04-08 11:44:25 +02:00
Olivier
b227e37758 Do not immediatly raise an exception when a variable is set to log exception 2025-03-31 21:17:14 +02:00
Olivier
82e7d3694f raise more precise error when we fail to send a request to server 2025-03-31 21:17:14 +02:00
Olivier
51b1f6875f run CI on newer python version 2025-03-31 21:17:00 +02:00
Olivier
95ef9f0d56 some formatting 2025-03-31 16:34:50 +02:00
Olivier
f38d7da0e6 stupid ruff formatting 2025-03-31 16:34:50 +02:00
Olivier
d59a037f3d some ruff things 2025-03-31 16:34:50 +02:00
Olivier
a7c7efed28 remove a test which has been failing for years without anyone finding out how it works 2025-03-31 16:34:50 +02:00
Olivier
e882441d36 disable test broken by 1.0.5 2025-03-31 16:34:50 +02:00
Olivier
50aaee2600 shelv cannot be created in another thread 2025-03-31 16:34:50 +02:00
Olivier
83a47ea7e5 fixes to code generate after nodeset update 2025-03-31 16:34:50 +02:00
Olivier
7924d98cc0 automatic nodeset update 2025-03-31 16:34:50 +02:00
Olivier
6815371933 fix tests for nodeset update 2025-03-31 16:34:50 +02:00
matt-williams
3f5d491721 Parse ExtensionObjects with missing length (= -1) (#1803)
* Parse ExtensionObjects with missing length (= -1)

Some old OPC/UA implementations omit the length when building ExtensionObjects and
instead specify -1 - for interoperability, assume this means the rest of the buffer

* Lint
2025-03-31 16:02:42 +02:00
Christoph Ziebuhr
e6d646d12f Fix ReferenceDescriptions for TypeDefinition
Fail if TypeDefinition is invalid
2025-03-13 10:29:14 +01:00
Christoph Ziebuhr
9f367549c5 Fix NodeClass in ReferenceDescriptions of UA-Nodeset 2025-03-09 19:22:38 +01:00
Christoph Ziebuhr
324295f068 Fix binary_address_space.pickle generation
generate_address_space.py used old address space for pickle generation,
which means you had to run it twice to get the new one
2025-03-09 19:22:38 +01:00
Olof Ohlsson Sax
f29d401c8c Add support for reading structure with subtyped values 2025-03-02 21:02:30 +01:00
Bi0T1N
1520d3c175 Add missing import for typing Optional 2025-03-02 21:01:43 +01:00
Tor Arvid Lund
772316de21 Use ObjectId instead of hard-coded int for DataValue type 2025-02-06 19:59:21 +01:00
Tor Arvid Lund
c95631e2e2 fix: NodeId change for class DataValue
According to ObjectIds, DataValue = 23, and not 25 as it was before this
commit. 25 is DiagnosticInfo, which can be seen below...
2025-02-06 19:59:21 +01:00
Andreas Heine
447bdf7596 add: Number in uatypes.py 2025-02-06 14:20:24 +01:00
Hector Oliveros
b1fe0b21b4 Update connection limit logging to check for changes (#1777)
* Update connection limit logging to check for changes

Added conditionals to log limit updates only when changes are detected, reducing unnecessary log noise. This applies to both server and client limit updates in the connection logic.

* Fix indentation in server and client limit updates

Adjusted indentation in the `update_limits` methods to ensure values are updated only when changes are detected. This aligns the logic with the condition and avoids unnecessary updates.

* Fix ruff format

---------

Co-authored-by: Hector Oliveros <holiveros.see@aminerals.cl>
2025-01-30 19:26:58 +01:00
Andreas Heine
c195f37cfc Update README.md 2025-01-22 11:45:47 +01:00
Andreas Heine
e7eb4df205 Update README.md 2025-01-22 11:45:26 +01:00
mver-al
b1cfae3466 Don't set _password and _username in activate_session. 2025-01-08 21:24:22 +01:00
mver-al
78a86a9254 Allow setting password to None. 2025-01-08 21:24:22 +01:00
mver-al
af95fff1fd Fixes for using activate_session to change users.
- The updated ServerNonce was not saved after activate_session, which
  means that subsequent activate_sessions would fail with
  BadIdentityTokenInvalid.
- The _username and _password attributes of Client were never updated but
  checked in the code (_add_user_auth function).
2025-01-08 21:24:22 +01:00
Christoph Ziebuhr
3c6317be7b Fix usage of X509IdentityToken
- sign token with algorithm from policy uri
- verify signature in server!
2024-12-04 13:55:40 +01:00
Christoph Ziebuhr
9f7322946f Improve user token policy selection 2024-12-04 13:55:40 +01:00
Christoph Ziebuhr
594dcad8bc Improve usage of UserTokenPolicy.SecurityPolicyUri
Don't allow plaintext password to prevent BadSecurityModeInsufficient in some clients
2024-12-04 13:55:40 +01:00
Christoph Ziebuhr
d5ce251b9a Move SecurityPolicy from ua to crypto 2024-12-04 13:55:40 +01:00