async def open_secure_channel(self, renew=False): """ Open secure channel, if renew is True, renew channel """ params = ua.OpenSecureChannelParameters() params.ClientProtocolVersion = 0 params.RequestType = ua.SecurityTokenRequestType.Issue if renew: params.RequestType = ua.SecurityTokenRequestType.Renew params.SecurityMode = self.security_policy.Mode params.RequestedLifetime = self.secure_channel_timeout # length should be equal to the length of key of symmetric encryption params.ClientNonce = create_nonce(self.security_policy.symmetric_key_size) result = await self.uaclient.open_secure_channel(params) if self.secure_channel_timeout != result.SecurityToken.RevisedLifetime: _logger.info("Requested secure channel timeout to be %dms, got %dms instead", self.secure_channel_timeout, result.SecurityToken.RevisedLifetime) self.secure_channel_timeout = result.SecurityToken.RevisedLifetime
async def open_secure_channel(self, renew=False): """ Open secure channel, if renew is True, renew channel """ params = ua.OpenSecureChannelParameters() params.ClientProtocolVersion = 0 params.RequestType = ua.SecurityTokenRequestType.Issue if renew: params.RequestType = ua.SecurityTokenRequestType.Renew params.SecurityMode = self.security_policy.Mode params.RequestedLifetime = self.secure_channel_timeout # length should be equal to the length of key of symmetric encryption nonce = create_nonce(self.security_policy.symmetric_key_size) params.ClientNonce = nonce # this nonce is used to create a symmetric key result = await self.uaclient.open_secure_channel(params) self.security_policy.make_symmetric_key(nonce, result.ServerNonce) self.secure_channel_timeout = result.SecurityToken.RevisedLifetime