MCPcopy Create free account
hub / github.com/FreeOpcUa/python-opcua / open_secure_channel

Method open_secure_channel

opcua/client/client.py:322–340  ·  view source on GitHub ↗

Open secure channel, if renew is True, renew channel

(self, renew=False)

Source from the content-addressed store, hash-verified

320 raise ack
321
322 def open_secure_channel(self, renew=False):
323 """
324 Open secure channel, if renew is True, renew channel
325 """
326 params = ua.OpenSecureChannelParameters()
327 params.ClientProtocolVersion = 0
328 params.RequestType = ua.SecurityTokenRequestType.Issue
329 if renew:
330 params.RequestType = ua.SecurityTokenRequestType.Renew
331 params.SecurityMode = self.security_policy.Mode
332 params.RequestedLifetime = self.secure_channel_timeout
333 # length should be equal to the length of key of symmetric encryption
334 params.ClientNonce = utils.create_nonce(self.security_policy.symmetric_key_size) # this nonce is used to create a symmetric key
335 result = self.uaclient.open_secure_channel(params)
336 if self.secure_channel_timeout != result.SecurityToken.RevisedLifetime:
337 _logger.warning("Requested secure channel timeout to be %dms, got %dms instead",
338 self.secure_channel_timeout,
339 result.SecurityToken.RevisedLifetime)
340 self.secure_channel_timeout = result.SecurityToken.RevisedLifetime
341
342 def close_secure_channel(self):
343 return self.uaclient.close_secure_channel()

Callers 5

connectMethod · 0.95
runMethod · 0.45

Calls

no outgoing calls

Tested by

no test coverage detected