From da82840709338ab236270f7d84c8d5bb1ea865b3 Mon Sep 17 00:00:00 2001 From: Max Kirchberger Date: Fri, 16 Feb 2024 10:17:34 +0100 Subject: [PATCH 1/3] reuse the identity plicy that has been used earlier --- Libraries/Opc.Ua.Client/Session.cs | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/Libraries/Opc.Ua.Client/Session.cs b/Libraries/Opc.Ua.Client/Session.cs index a0e4bfb07..5d09b150b 100644 --- a/Libraries/Opc.Ua.Client/Session.cs +++ b/Libraries/Opc.Ua.Client/Session.cs @@ -5523,8 +5523,12 @@ ITransportChannel transportChannel EndpointDescription endpoint = m_endpoint.Description; SignatureData clientSignature = SecurityPolicies.Sign(m_instanceCertificate, endpoint.SecurityPolicyUri, dataToSign); - // check that the user identity is supported by the endpoint. - UserTokenPolicy identityPolicy = endpoint.FindUserTokenPolicy(m_identity.TokenType, m_identity.IssuedTokenType); + UserTokenPolicy identityPolicy = m_endpoint.Description.FindUserTokenPolicy(m_identity.PolicyId); + if (identityPolicy == null) + { + // check that the user identity is supported by the endpoint. + identityPolicy = endpoint.FindUserTokenPolicy(m_identity.TokenType, m_identity.IssuedTokenType); + } if (identityPolicy == null) { From 8e79e62d3bdd81eb2c3af18ccf1a8109ebfb1a7e Mon Sep 17 00:00:00 2001 From: Max Kirchberger Date: Fri, 16 Feb 2024 10:19:32 +0100 Subject: [PATCH 2/3] pass the existing cancellation token to the sessionfactories createasync call --- Applications/ConsoleReferenceClient/UAClient.cs | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/Applications/ConsoleReferenceClient/UAClient.cs b/Applications/ConsoleReferenceClient/UAClient.cs index 51c49193e..1e47b4fea 100644 --- a/Applications/ConsoleReferenceClient/UAClient.cs +++ b/Applications/ConsoleReferenceClient/UAClient.cs @@ -190,7 +190,8 @@ public async Task ConnectAsync(string serverUrl, bool useSecurity = true, m_configuration.ApplicationName, SessionLifeTime, UserIdentity, - null + null, + ct ).ConfigureAwait(false); // Assign the created session From 85aac283a15e409c337977022860ff6ae0a7ffcf Mon Sep 17 00:00:00 2001 From: Max Kirchberger Date: Thu, 22 Feb 2024 15:34:36 +0100 Subject: [PATCH 3/3] remove second identity policy get -> should never be null after the first call --- Libraries/Opc.Ua.Client/Session.cs | 5 ----- 1 file changed, 5 deletions(-) diff --git a/Libraries/Opc.Ua.Client/Session.cs b/Libraries/Opc.Ua.Client/Session.cs index 5d09b150b..87e8a03e6 100644 --- a/Libraries/Opc.Ua.Client/Session.cs +++ b/Libraries/Opc.Ua.Client/Session.cs @@ -5524,11 +5524,6 @@ ITransportChannel transportChannel SignatureData clientSignature = SecurityPolicies.Sign(m_instanceCertificate, endpoint.SecurityPolicyUri, dataToSign); UserTokenPolicy identityPolicy = m_endpoint.Description.FindUserTokenPolicy(m_identity.PolicyId); - if (identityPolicy == null) - { - // check that the user identity is supported by the endpoint. - identityPolicy = endpoint.FindUserTokenPolicy(m_identity.TokenType, m_identity.IssuedTokenType); - } if (identityPolicy == null) {