Skip to content

Commit a7f21f7

Browse files
author
TurtleDogBird
authored
Simple fix suggested by brubbel. (#1135)
* Simple fix suggested by brubbel. * Shorter notation, without pass.
1 parent f51d14c commit a7f21f7

File tree

2 files changed

+11
-3
lines changed

2 files changed

+11
-3
lines changed

opcua/common/connection.py

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -299,7 +299,12 @@ def receive_from_header_and_body(self, header, body):
299299
if header.MessageType == ua.MessageType.SecureOpen:
300300
data = body.copy(header.body_size)
301301
security_header = struct_from_binary(ua.AsymmetricAlgorithmHeader, data)
302-
self.select_policy(security_header.SecurityPolicyURI, security_header.SenderCertificate)
302+
303+
if not self.is_open():
304+
# Only call select_policy if the channel isn't open. Otherwise
305+
# it will break the Secure channel renewal.
306+
self.select_policy(security_header.SecurityPolicyURI, security_header.SenderCertificate)
307+
303308
elif header.MessageType in (ua.MessageType.SecureMessage, ua.MessageType.SecureClose):
304309
data = body.copy(header.body_size)
305310
security_header = struct_from_binary(ua.SymmetricAlgorithmHeader, data)

opcua/server/uaprocessor.py

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -51,8 +51,11 @@ def send_response(self, requesthandle, seqhdr, response, msgtype=ua.MessageType.
5151
def open_secure_channel(self, algohdr, seqhdr, body):
5252
request = struct_from_binary(ua.OpenSecureChannelRequest, body)
5353

54-
self._connection.select_policy(
55-
algohdr.SecurityPolicyURI, algohdr.SenderCertificate, request.Parameters.SecurityMode)
54+
if not self._connection.is_open():
55+
# Only call select_policy if the channel isn't open. Otherwise
56+
# it will break the Secure channel renewal.
57+
self._connection.select_policy(
58+
algohdr.SecurityPolicyURI, algohdr.SenderCertificate, request.Parameters.SecurityMode)
5659

5760
channel = self._connection.open(request.Parameters, self.iserver)
5861
# send response

0 commit comments

Comments
 (0)