Professional OPC
Development Tools

logos

Online Forums

Technical support is provided through Support Forums below. Anybody can view them; you need to Register/Login to our site (see links in upper right corner) in order to Post questions. You do not have to be a licensed user of our product.

Please read Rules for forum posts before reporting your issue or asking a question. OPC Labs team is actively monitoring the forums, and replies as soon as possible. Various technical information can also be found in our Knowledge Base. For your convenience, we have also assembled a Frequently Asked Questions page.

Do not use the Contact page for technical issues.

Unable to use Username/Password identity with SecurityPolicy 'None'

More
16 Feb 2021 10:03 #9451 by support
Hello,

this appears to be a bug in QuickOPC. I was able to reproduce it. Thank you for reporting. It will be fixed in the upcoming version (2021.1). For now, there is a workaround:

a) If you are using the EasyUAClient with default Isolated property setting (false):
EasyUAClient.AdaptableParameters.SessionParameters.AlwaysPreselectEndpoint = true;
b) if you have set EasyUAClient's Isolated property to 'true':
client.IsolatedParameters.SessionParameters.AlwaysPreselectEndpoint = true;
I hope this helps
Best regards

Please Log in or Create an account to join the conversation.

More
15 Feb 2021 15:45 #9448 by Mykola
Hello,

We have issue using a server endpoint with SecurityMode 'None' and SecurityPolicy "None" that requires client to provide username/password identity.
An internal "System.NullReferenceException" is thrown by QuickOPC.
We don't have that issue with endpoints that use different security policy or anonymous identity.

Server configuration:
<ServerSecurityPolicy>
        <SecurityMode>None_1</SecurityMode>
        <SecurityPolicyUri>http://opcfoundation.org/UA/SecurityPolicy#None</SecurityPolicyUri>
      </ServerSecurityPolicy>
    </SecurityPolicies>
    <UserTokenPolicies>
      <ua:UserTokenPolicy>
        <ua:TokenType>UserName_1</ua:TokenType>
      </ua:UserTokenPolicy>
    </UserTokenPolicies>

Our code (simplified):
var opcClient = new EasyUAClient() { Isolated = true };
var sessionParameters = opcClient.IsolatedParameters.SessionParameters;
sessionParameters.EndpointSelectionPolicy.AllowedMessageSecurityModes = OpcLabs.EasyOpc.UA.Engine.UAMessageSecurityModes.SecurityNone;
sessionParameters.EndpointSelectionPolicy.SecurityPolicyUri = new Uri("http://opcfoundation.org/UA/SecurityPolicy#None");
sessionParameters.UserIdentity.UserNameTokenInfo = new UserNameTokenInfo(_clientConfiguration.Username, _clientConfiguration.Password);
var endpointDescriptor = new UAEndpointDescriptor(_clientConfiguration.EndpointUrl);
var res = opcClient.BrowseDataNodes(endpointDescriptor);

Client log:
2021-02-15 17:32:05.970 [VRB] EasyUAClient Information OPCLabs-UAEngine: The OPC-UA engine will resolve the client instance certificate parameters directory store path to "C:\ProgramData\OPC Foundation\CertificateStores\MachineDefault".
2021-02-15 17:32:06.010 [VRB] EasyUAClient Information OPCLabs-UAEngine: The OPC-UA engine has determined the application configuration parameters as listed below. 
ProductUri: urn:literal:string:GenericTestTool
2021-02-15 17:32:06.078 [VRB] EasyUAClient Information OPCLabs-EasyUAClient: Licensing for EasyUAClient component started, license serial number *******, issuer name "OPC Labs", subject name "***************".
2021-02-15 17:32:06.268 [VRB] EasyUAClient Information OPCLabs-UAEngine: External information from "InteractionProviderCompositor" (0,1): Newly selected interaction handler is 'Console'.
2021-02-15 17:32:06.329 [VRB] EasyUAClient Information OPCLabs-UAEngine: The OPC-UA engine has successfully connected to the underlying subsystems.
2021-02-15 17:32:06.444 [VRB] EasyUAClient Information OPCLabs-UAEngine: The OPC-UA client session with connect sequence number 1 is connecting to endpoint URL "opc.tcp://localhost:9090/GenericSimulator".
2021-02-15 17:32:06.468 [VRB] EasyUAClient Information OPCLabs-UAEngine: The OPC-UA client session with connect sequence number 1 has synthesized an OPC-UA endpoint (without preselection) with following parameters:
Endpoint URL "opc.tcp://localhost:9090/GenericSimulator", message security mode 'None', security policy URI "http://opcfoundation.org/UA/SecurityPolicy#None", transport profile URI ", server certificate presented: no, use binary encoding: yes.
2021-02-15 17:32:06.733 [VRB] EasyUAClient Information OPCLabs-UAEngine: OPC-UA endpoint selection on discovery URL "opc.tcp://localhost:9090/GenericSimulator" candidate report (1 entries) follows.
[0:Winner(1000+0)].
2021-02-15 17:32:06.743 [VRB] EasyUAClient Information OPCLabs-UAEngine: The OPC-UA client session with connect sequence number 1 user token selection on endpoint URL "opc.tcp://localhost:9090/GenericSimulator" candidate report (1 entries) follows.
[0:Winner("http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-username-token-profile-1.0")].
2021-02-15 17:32:06.745 [VRB] EasyUAClient Information OPCLabs-UAEngine: The OPC-UA client session with connect sequence number 1 on endpoint URL "opc.tcp://localhost:9090/GenericSimulator" has been associated with user identity token type 'UserName', display name "qqqq".
2021-02-15 17:32:06.773 [VRB] EasyUAClient Error OPCLabs-UAEngine: INTERNAL ERROR. The OPC-UA engine might be in an unstable state. 
  An exception of type "System.NullReferenceException" from source "Opc.Ua.Core" has occurred in OPC-UA SDK action 'static Session.Create'. The exception descend follows.
(1) {System.NullReferenceException} Opc.Ua.Core(GetPlainTextBlockSize) -> Object reference not set to an instance of an object.
 
2021-02-15 17:32:06.781 [VRB] EasyUAClient Warning OPCLabs-UAEngine: The OPC-UA client session with connect sequence number 1 failed to connect to endpoint URL "opc.tcp://localhost:9090/GenericSimulator". 
  INTERNAL ERROR. An exception of type "System.NullReferenceException" from source "Opc.Ua.Core" has occurred in OPC-UA SDK action 'static Session.Create'. The exception descend follows.
(1) {System.NullReferenceException} Opc.Ua.Core(GetPlainTextBlockSize) -> Object reference not set to an instance of an object.
 
+ Following (15) events were gathered during the action on activity ID [3], in the order of first occurrence:
  SDK trace: CreateSession Called. RequestHandle=1, PendingRequestCount=1
  [4] SDK trace: Token #0 created. CreatedAt = 15:32:06.611 . Lifetime = 3600000
  [4] SDK trace: Token #1 activated. CreatedAt = 15:32:06.611 . Lifetime = 3600000
  SDK trace: CreateSession Completed. RequestHandle=1, PendingRequestCount=0
  SDK trace: Revised session timeout value: 600000. 
  SDK trace: Max response message size value: 4194304. Max request message size: 4194304 
  SDK trace: Server signature is null or empty.
  SDK trace: CloseSession Called. RequestHandle=2, PendingRequestCount=1
  SDK trace: CloseSession Completed. RequestHandle=2, PendingRequestCount=0
  [7] SDK trace: TCPCLIENTCHANNEL SOCKET CLOSED: 00000B0C, ChannelId=1
  Exception: {Opc.Ua.ServiceResultException} BadSecureChannelClosed
  SDK trace: CloseSession Called. RequestHandle=3, PendingRequestCount=1
  2*Exception: {System.ObjectDisposedException} Cannot access a disposed object.
  SDK trace: CloseSession Completed. RequestHandle=3, PendingRequestCount=0, StatusCode=Bad
+ Events starting with activity ID in [] may not necessarily be related to the current action.
2021-02-15 17:32:06.783 [VRB] EasyUAClient Information OPCLabs-UAEngine: The OPC-UA client session on endpoint URL "opc.tcp://localhost:9090/GenericSimulator" failed at tick 6651770453 and will retry in 10000 milliseconds.
2021-02-15 17:32:06.791 [VRB] EasyUAClient Warning OPCLabs-UAEngine: The status subscription for an OPC-UA session on endpoint URL "opc.tcp://localhost:9090/GenericSimulator" is in failure. Further such warnings on this session will not be logged.
INTERNAL ERROR. An exception of type "System.NullReferenceException" from source "Opc.Ua.Core" has occurred in OPC-UA SDK action 'static Session.Create'. The exception descend follows.
(1) {System.NullReferenceException} Opc.Ua.Core(GetPlainTextBlockSize) -> Object reference not set to an instance of an object.
 
+ Following (15) events were gathered during the action on activity ID [3], in the order of first occurrence:
  SDK trace: CreateSession Called. RequestHandle=1, PendingRequestCount=1
  [4] SDK trace: Token #0 created. CreatedAt = 15:32:06.611 . Lifetime = 3600000
  [4] SDK trace: Token #1 activated. CreatedAt = 15:32:06.611 . Lifetime = 3600000
  SDK trace: CreateSession Completed. RequestHandle=1, PendingRequestCount=0
  SDK trace: Revised session timeout value: 600000. 
  SDK trace: Max response message size value: 4194304. Max request message size: 4194304 
  SDK trace: Server signature is null or empty.
  SDK trace: CloseSession Called. RequestHandle=2, PendingRequestCount=1
  SDK trace: CloseSession Completed. RequestHandle=2, PendingRequestCount=0
  [7] SDK trace: TCPCLIENTCHANNEL SOCKET CLOSED: 00000B0C, ChannelId=1
  Exception: {Opc.Ua.ServiceResultException} BadSecureChannelClosed
  SDK trace: CloseSession Called. RequestHandle=3, PendingRequestCount=1
  2*Exception: {System.ObjectDisposedException} Cannot access a disposed object.
  SDK trace: CloseSession Completed. RequestHandle=3, PendingRequestCount=0, StatusCode=Bad
+ Events starting with activity ID in [] may not necessarily be related to the current action.
2021-02-15 17:32:09.835 [ERR] An error occured while initializing client
OpcLabs.EasyOpc.UA.OperationModel.UAException: An OPC-UA operation failure with error ID 'OpcLabs.BaseLib.Portable.CustomException' occurred, originating from 'Opc.Ua.Core' and with depth of 2. The inner exception, of type "OpcLabs.BaseLib.Portable.CustomException", contains details about the problem. ---> OpcLabs.BaseLib.Portable.CustomException: INTERNAL ERROR. An exception of type "System.NullReferenceException" from source "Opc.Ua.Core" has occurred in OPC-UA SDK action 'static Session.Create'. The exception descend follows.
(1) {System.NullReferenceException} Opc.Ua.Core(GetPlainTextBlockSize) -> Object reference not set to an instance of an object.

Please Log in or Create an account to join the conversation.

Moderators: support
Time to create page: 0.111 seconds