Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
O
opcua-asyncio
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
1
Merge Requests
1
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Analytics
Analytics
CI / CD
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Nikola Balog
opcua-asyncio
Commits
129344e7
Commit
129344e7
authored
Oct 31, 2020
by
Randolph Busch
Committed by
oroulet
Nov 24, 2020
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
new approach to the new security token race condition
parent
fe513feb
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
16 additions
and
5 deletions
+16
-5
asyncua/client/ua_client.py
asyncua/client/ua_client.py
+16
-5
No files found.
asyncua/client/ua_client.py
View file @
129344e7
...
...
@@ -39,6 +39,9 @@ class UASocketProtocol(asyncio.Protocol):
self
.
_connection
=
SecureConnection
(
security_policy
)
self
.
state
=
self
.
INITIALIZED
self
.
closed
:
bool
=
False
# needed to pass params from asynchronous request to synchronous data receive callback, as well as
# passing back the processed response to the request so that it can return it.
self
.
_open_secure_channel_exchange
=
None
def
connection_made
(
self
,
transport
:
asyncio
.
Transport
):
self
.
state
=
self
.
OPEN
...
...
@@ -78,6 +81,11 @@ class UASocketProtocol(asyncio.Protocol):
return
msg
=
self
.
_connection
.
receive_from_header_and_body
(
header
,
buf
)
self
.
_process_received_message
(
msg
)
if
header
.
MessageType
==
ua
.
MessageType
.
SecureOpen
:
params
=
self
.
_open_secure_channel_exchange
self
.
_open_secure_channel_exchange
=
struct_from_binary
(
ua
.
OpenSecureChannelResponse
,
msg
.
body
())
self
.
_open_secure_channel_exchange
.
ResponseHeader
.
ServiceResult
.
check
()
self
.
_connection
.
set_channel
(
self
.
_open_secure_channel_exchange
.
Parameters
,
params
.
RequestType
,
params
.
ClientNonce
)
if
not
buf
:
return
# Buffer still has bytes left, try to process again
...
...
@@ -207,14 +215,17 @@ class UASocketProtocol(asyncio.Protocol):
self
.
logger
.
info
(
"open_secure_channel"
)
request
=
ua
.
OpenSecureChannelRequest
()
request
.
Parameters
=
params
result
=
await
asyncio
.
wait_for
(
if
self
.
_open_secure_channel_exchange
is
not
None
:
raise
RuntimeError
(
'Two Open Secure Channel requests can not happen too close to each other. '
'The response must be processed and returned before the next request can be sent.'
)
self
.
_open_secure_channel_exchange
=
params
await
asyncio
.
wait_for
(
self
.
_send_request
(
request
,
message_type
=
ua
.
MessageType
.
SecureOpen
),
self
.
timeout
)
response
=
struct_from_binary
(
ua
.
OpenSecureChannelResponse
,
result
)
response
.
ResponseHeader
.
ServiceResult
.
check
()
self
.
_connection
.
set_channel
(
response
.
Parameters
,
params
.
RequestType
,
params
.
ClientNonce
)
return
response
.
Parameters
_return
=
self
.
_open_secure_channel_exchange
.
Parameters
self
.
_open_secure_channel_exchange
=
None
return
_return
async
def
close_secure_channel
(
self
):
"""
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment