nauful / libua Goto Github PK
View Code? Open in Web Editor NEWOpen-source OPC UA client and server library
License: Apache License 2.0
Open-source OPC UA client and server library
License: Apache License 2.0
Hi again. Using the server example I think everything updates fine but I get these errors in the UAExpert console. What do they mean ?. Is everything working correctly ?.
https://www.dropbox.com/s/xfkvd85kxi1m5hc/error.jpg?dl=0
Thank you.
It's the first time I use this library and I try to wrote e test program using this library but I get a BadUnknownResponse during the ActivateSession method, what did I make wrong? see the followin snippet:
Thanks in advance
appDesc = new ApplicationDescription("urn:DyeMrp", "uri:DyeMrp", new LocalizedText("UA client"), ApplicationType.Client, null, null, null);
client = new Client(args[0], 4840, 1000);
var connectRes = client.Connect();
if (connectRes != StatusCode.Good)
{
Console.WriteLine($"OPC OpenChannel Connect error: {connectRes}");
Environment.Exit(1);
}
Console.WriteLine(connectRes);
var openRes = client.OpenSecureChannel(MessageSecurityMode.None, SecurityPolicy.None, null);
if (openRes != StatusCode.Good)
{
Console.WriteLine($"OPC OpenChannel OpenSecureChannel error: {openRes}");
Environment.Exit(1);
}
Console.WriteLine(openRes);
var createRes = client.CreateSession(appDesc, "urn:ProcessMachine", 120);
if (createRes != StatusCode.Good)
{
Console.WriteLine($"OPC OpenChannel CreateSession error: {createRes}");
Environment.Exit(1);
}
Console.WriteLine(createRes);
var activateRes = client.ActivateSession(new UserIdentityAnonymousToken("0"), new[] { "it" });
if (activateRes != StatusCode.Good)
{
Console.WriteLine($"OPC OpenChannel ActivateSession error: {activateRes}");
Environment.Exit(1);
}
Console.WriteLine(activateRes);
According to the OPC foundation, the security policies Basic256 and Basic128Rsa15 are obsolete. Is there any plan to implement e.g. Basic256Sha256?
I'm using your open source LibUA package to experiment with your OPC UA Server. I downloaded a copy back in January 2020 and haven't updated it since. We have a couple of machine control programs that currently contain DA servers, and we want to revise them to use UA. So I've put your LibUA server code into a class library for testing. So far we are pleased with the results. I typically use the UaExpert client for connections to the server. It looks like the publish/subscribe features are not finished yet. In UaExpert I can drag a tag from the Address Space panel into the Data Access View panel. That causes the client to request that the server create a new subscription via message type 787 (and the server does create the subscription). Then the client requests that the tag be placed in a monitored item list via message type 751 (looks like that is also working). But when the client sends a publish request message (type 826) to the server, nothing else happens. Do you have any information or advice about this
problem?
I see a function MonitorNotifyDataChange() that is never called. Was that intended to be part of the pub/sub scheme?
Hello nauful,
Thank you for your work!
I have some problem with OpenAsync with UA Automation SDK Client Example(https://www.unified-automation.com/news/news-details/article/new-net-based-opc-ua-clientserver-sdk-v305-service-release.html) and Convertersystems\opc-ua-client (https://github.com/convertersystems/opc-ua-client)
Endpoint Discover is Ok, but then I chose Endpoint and try to connect:
Then I try None secure connection, I have 1-3 messages like: [Info] 127.0.0.1:13813: Message type ns=0;i=428 with SL state Opening and then [Info] Ended connection from 127.0.0.1:14290.
Then I try Basic256Sha256 secure connection, I have 1-3 messages like: [Info] 127.0.0.1:13813: Message type ns=0;i=428 with SL state Opening and then [Error] Sent TL error 0x80070000, [Info] Ended connection from 127.0.0.1:14290.
If you have some time can you check? For save time you can use opc-ua-client, they have Unit Tests -> IntegrationTests.cs -> ConnnectToAllEndpoints().
Hello,
I continue exploring your library, and it looks very promissing.
The final goal of my project is to connect to SIMATIC WinCC. My application is a server. Everything works fine with clients like UAExpert and other, but when I try to connect from SIMATIC WinCC I've got the following:
The Consume gives (-4), exception is: "Error occurred while decoding OAEP padding". Decoding problem, maybe because the private key is wrong, but I don't have a PEM file for the certificate from ERRATA.
3.With security Basic128Rsa15 and the original certificate i get Unknown error, but things look better
WIreshark log:
SecurityBasic128Rsa15_org_cert.zip
Please help me solve this issue!
Thanks in advance
Hi, i try to create a Subscription with using datachangedfilter monitor variable. I write my code and i don't khow to use where you find "DataChangeFilter .... ??"
uint subscrId;
client.CreateSubscription(0, 1000, true, 0, out subscrId);
// Second will have response BadSubscriptionIdInvalid
client.SetPublishingMode(true, new[] {subscrId, 10u}, out var respStatuses);
uint respStatus;
client.ModifySubscription(subscrId, 0, 100, true, 0, out respStatus);
uint clientHandleEventMonitor = 0;
var tagsMonitorId = new uint[2];
for (var i = 0; i < 2; i++) tagsMonitorId[i] = (uint) (1 + i);
MonitoredItemCreateResult[] monitorCreateResults;
client.CreateMonitoredItems(subscrId, TimestampsToReturn.Both,
new[]
{
new MonitoredItemCreateRequest(
new ReadValueId(new NodeId(2, "PLC_GE_P10.D1.R7001 S"), NodeAttribute.EventNotifier, null, new QualifiedName()),
MonitoringMode.Reporting,
new MonitoringParameters(clientHandleEventMonitor, 0, "DataChangeFilter .... ??", 100, true)),
new MonitoredItemCreateRequest(
new ReadValueId(new NodeId(2, "PLC_GE_P10.D1.R7003 L"), NodeAttribute.Value, null, new QualifiedName()),
MonitoringMode.Reporting,
new MonitoringParameters(tagsMonitorId[0], 0, null, 100, false)),
new MonitoredItemCreateRequest(
new ReadValueId(new NodeId(2, "PLC_GE_P10.D1.R7005 L"), NodeAttribute.Value, null, new QualifiedName()),
MonitoringMode.Reporting,
new MonitoringParameters(tagsMonitorId[1], 0, null, 100, false)),
}, out monitorCreateResults);
How can i use DataChangeFilter?
Thanks in advance
Hi. I'm researching your library and wanted to implement parent node creation and deletion. To delete, I wrote the following method:
public void TryRemoveChieldNode(Node chieldNode, Application application)
{
try
{
this.References.Remove(this.References.Find(refNode => refNode.Target == chieldNode.Id));
chieldNode.References.Remove(chieldNode.References.Find(refNode => refNode.Target == this.Id));
Node node;
application.AddressSpaceTable.TryRemove(chieldNode.Id, out node);
}
catch { }
}
The node becomes unavailable but is not deleted on the client. Tell me, if possible, how to remove a node? I think it is necessary for the client to call HandleBrowseRequest (). How to do this, can you tell me, please?
The title says it all, after opening a secure channel with security Policy set to none to get the endpoints, I disconnect the client but always get a BadNotConnected as a return value. I was expecting after a successful disconnect to receive the Good result.
I was unable to authenticate using the SecurityPolicy Basic256 and the reference server of the OPC foundation.
I was able to open a secure channel and creating a session using:
m_client.OpenSecureChannel(MessageSecurityMode.SignAndEncrypt, SecurityPolicy.Basic256, serverCert);
m_client.CreateSession(appDesc, "urn:Application", 2);
But activating the session using:
m_client.ActivateSession( new UserIdentityUsernameToken(usernamePolicyDesc, "Name", (new UTF8Encoding()).GetBytes("password"), "http://www.w3.org/2001/04/xmlenc#rsa-oaep"), new[] { "en" });
did not work.
After looking at the code to activate the session, shouldn't the actual SecurityPolicy (which is available in the config member) be used when calculating the padding size and when encrypting the password instead of the hard coded Basic128Rsa15 SecurityPolicy?
Hi Nauful, we would like to know if LibUA has the OPC Foundation Certification. We have found this possibility here:
https://opcfoundation.org/certification/how-to-certify/
Best Regards.
I was trying to connect the client to the OPC foundation reference server, but was unable to connect. During my search as to why it wouldn't connect I found out I wasn't receiving the error message type of the server. The reference server uses ID 0x525245, and in the LibUA code I find ID 0x515145 (Line 39 in Types.cs).
After I changed the ID into 0x525245 I was able to receive the error message and found out I was using a security policy which wasn't enabled on the server side.
Your project is great, it helped me a lot, but I don’t understand NodeMethod
Can you provide the demo of nodemethod, thank you
The node "Items\Trend 000001" value and datatype is different if monitoring or reading it. If monitoring, the value and datatype is correct. When reading, a constant value of "3.14159265" is shown and the datatype is invalid. Tested with UAExpert-UAClient.
Dear @nauful,
Thank you again for your freely available code!
Regarding the server implementation:
I'm currently trying to support InputArguments/OutputArguments for a NodeMethod, which I added successfully according to #23.
I was able to add the reference nodes to my NodeMethod "method":
// argument nodes
method.References.Add(new ReferenceNode(new NodeId(UAConst.HasProperty), new NodeId(UAConst.InputArguments), false));
method.References.Add(new ReferenceNode(new NodeId(UAConst.HasProperty), new NodeId(UAConst.OutputArguments), false));
However, I don't know how to add, for example, a string InputArgument to "method".
I just found the "Argument = 296" definition in Types.cs but I think I lack understanding how to add InputArguments here.
Any advice is very much appreciated.
Thank you very much!
Hi, we have been talking in my company about the possibility of certifying the LibUA library through the OPCFoundation. If possible, we would like to contact you privately to discuss certain aspects of the process, as we understand that this site is not suitable as it is not a problem with LibUA. So, if you agree, tell us how to contact you directly.
Thanks for your time.
Hi, I have a problem using TestServer and trying to connect the UaExpert client. I use the TestServer example provided in the repository as it is and I can't connect to that client. I would appreciate if you could show me how to configure the connection for that client or if you could explain to me the new ApplicationDescription () function.
Thank you.
Hi, I try to connect to Matrikon OPC UA Explorer but it not find endpoints. I get following error in Matrikon OPC UA Explorer console: No endpoints available for URL.
I use Net Core\TestServer.
Hello, this is the first time I am using this library.
I wrote a test program to connect to an OPC UA server located on a remote VPN server. The server is accessible without any type of encryption or username / password.
The library goes into exception during the call to the CreateSession, in the DECODE function as the byte ENCODINGMASK is not recognized.
This is the part of the code:
var appDesc = new ApplicationDescription("urn:Demo","uri:Demo",new LocalizedText("UA client"),ApplicationType.Client,null,null,null);
// Create new client object to reset previous secure channel settings
var client = new Client("172.16.34.215", 4841, 1000);
var connectRes = client.Connect();
if (connectRes != StatusCode.Good)
{
Console.WriteLine($"OPC Connect error: {connectRes}");
Environment.Exit(1);
}
var openRes = client.OpenSecureChannel(MessageSecurityMode.None, SecurityPolicy.None, null);
if (openRes != StatusCode.Good)
{
Console.WriteLine($"OPC OpenSecureChannel error: {openRes}");
Environment.Exit(1);
}
var createRes = client.CreateSession(appDesc, "urn:Demo", 120);
if (createRes != StatusCode.Good)
{
Console.WriteLine($"OPC CreateSession error: {createRes}");
Environment.Exit(1);
}
var activateRes = client.ActivateSession(new UserIdentityAnonymousToken("0"), new[] { "en" });
if (activateRes != StatusCode.Good)
{
Console.WriteLine($"OPC ActivateSession error: {activateRes}");
Environment.Exit(1);
}
Can I have some ideas?
Thanks,
Paolo
Hello, I'm trying to use your library in one of my projects.
I want to handle OnSubscribe and OnUnsubscribe events.
The idea is to find which nodes are subscribed in a given moment and provide values for them. In my project values are read asynchronously, so I need to tell the other part of the program to read from the external device.
Please tell me what is the best way to achive that?
Hi,
Sorry, I am so new to OPCUA and I only need to read a couple's data points using Node ID.
I am using a demo version of Kepware OPC UA Client and all I have to do is specified the server IP address and port number. After that, I can read any node id.
I am connecting to the server without any security at this point.
Could you point out which functions that allow me to read a single node id in your LibUA?
Thanks a lot
Hello,
i would to read a struct array: for example i need to read un array of 10 elements witch one element is composed from 5 variables type int.
How i can do this?
Thanks alot
Hello,
I think I found a bug in LibUA.UASecurity. When you use MemoryStream.GetBuffer(), it may contain nulls at the end. It should be MemoryStream.ToArray() instead.
I needed a 2048 b long key and the exported .pem file had null characters at the end. It caused trouble when importing the file later, Base64 decoding didn't work.
Best regards
Jiri
Hello,
Thank you for your OPC implemantation !
In the file AddressSpace, you create all types of nodes but you always create them in NodeObject type rather than the right type, is that intentional?
For example, for the NodeObjectType the constructor is :
public NodeObjectType(NodeId Id, QualifiedName BrowseName, LocalizedText DisplayName, LocalizedText Description, UInt32 WriteMask, UInt32 UserWriteMask, bool IsAbstract)
: base(Id, NodeClass.Object, BrowseName, DisplayName, Description, WriteMask, UserWriteMask)
But it will be better is if was that ?
public NodeObjectType(NodeId Id, QualifiedName BrowseName, LocalizedText DisplayName, LocalizedText Description, UInt32 WriteMask, UInt32 UserWriteMask, bool IsAbstract)
: base(Id, NodeClass.ObjectType, BrowseName, DisplayName, Description, WriteMask, UserWriteMask)
Is there a possiblity to support .net core?
There are no app.config files in TestClient and TestServer projects, is there any special config or can a default app.config file be added to them?
This might seem like a newbie question but i cant seem to figure out how to create methods with input and output arguments.
I created a server with several folders, properties and methods, and all are being displayed correctly in UaMaster. However all the methods created do not have input arguments and/or output arguments(the node exists but not the argument value array).
I already tried to add arguments using references, fiddled around with the input arguments value and with the HandleReadRequestInternal to no avail.
Can i get some tips?
Thanks in advance.
Hi, I have problems with Prosys OPC UA Client. Using the provided server example, when I make a subscription (monitor) to a variable, it doesn't show any data (value).
Download Prosys OPC UA Client from my Dropbox here.
Thanks for you support.
Downloaded LibUA at end of April and compiled the Test Server. With server running, connected with the UaExpert client (version 1.5.1.331). During first attempt, the UaExpert Certificate Validation dialog popped up and contained error message "SubjectAltName is missing - this extension is mandatory according to the UA specification". Continued by pressing "Trust Server in Certificate". Subsequent connections by UaExpert client all pop the Connect Error dialog with message "Error 'BadCertificateHostNameInvalid' was returned during CreateSession, press 'Ignore' to suppress the error and continue connecting." After pressing Ignore, everything worked normally. But need to avoid the operator acknowledgement every time UaExpert connects. All online research suggests that the server certificate needs to include the SubjectAltName field to avoid this error. Please suggest how to add this parameter to your self-generated certificates. Thanks.
Hello engineers, What version of the specification is supported by libua?
Monitoring "Item\Trend 000001" with UAExpert delivers every second this log-messages in UAExpert's log output:
Error: Number of acknowledgement results (0) does not match number of acknowledgements (2)
Error: UaSessionPrivate::publishCallback - List of available sequence numbers is empty, at least current sequence number has to be available
how this server connect trough IEC104 or Modbus protocol?
I downloaded the repo and compiling everything, and ran the client and server test apps, and they both raise exceptions.
In the demo server, i see "ServerDiagnostics" nodes. But in UAExpert's "Server Diagnostics View" no information is shown in "Server Information", "Session Diagnostics" and "Subscription Diagnostics".
Is uaserver diagnostics supported?
I try to implement my very small Server and I am just starting, so I struggle a little bit with basics right now...
is it possible to set the initial values of a NodeVariable
or is it mandatory to use MonitorNotifyDataChange to give the DataType and Value to the Client?
And how could I declare a Node of Type array of bytes ?
Thanks for any pointers.
Hi nauful,
Thank you very much for your OPC-UA implementation!
I'm currently testing your test server implementation and saw that the following method, which is related to the session, is not implemented yet:
public override object SessionCreate(SessionCreationInfo sessionInfo)
{
// Create and return a session object with sessionInfo
return null;
}
Can you give me any advice on what object has to be created and returned in SessionCreate() and how to respond this to a client?
Is there already a predefined type available?
Thank you very much in advance!
The uaexpert client can show input- and output value fields build from type information supported by the method node. Did libua demo server support these informations?
Hi,
I am trying to monitor some items.
In general it works, however value changes are sporadically skipped and the NotifyDataChangeNotifications method is not executed.
The connection remains. Then it works again.
Did I do something wrong during the initialization or do you have an idea where the problem could be?
Thanks in advance :-)
Public Sub Create()
_client = New OPCClient(SERVER_ADDRESS, SERVER_PORT, 1000)
_client.Connect()
If _client.IsConnected Then
Dim applicationDescription As New ApplicationDescription(
"urn:" & APPLICATION_NAME,
"uri:" & APPLICATION_NAME,
New LocalizedText(APPLICATION_NAME),
ApplicationType.Client,
Nothing,
Nothing,
Nothing
)
_client.OpenSecureChannel(MessageSecurityMode.None, SecurityPolicy.None, Nothing)
_client.CreateSession(applicationDescription, "urn:" & APPLICATION_NAME, 120)
_client.ActivateSession(New UserIdentityAnonymousToken("0"), {"en"})
_client.CreateSubscription(0, 1000, True, 0, _subscrId)
Dim respStatuses As UInteger() = Nothing
_client.SetPublishingMode(True, {_subscrId}, respStatuses)
Dim monitorCreateResults As MonitoredItemCreateResult() = Nothing
_client.CreateMonitoredItems(
_subscrId,
TimestampsToReturn.Both,
New MonitoredItemCreateRequest() {
New MonitoredItemCreateRequest(
New ReadValueId(
New NodeId(3, NODE_NAME),
NodeAttribute.Value,
Nothing,
New QualifiedName()
),
MonitoringMode.Reporting,
New MonitoringParameters(0, 0, Nothing, 100, False)
)
},
monitorCreateResults
)
End If
End Sub
Imports LibUA
Imports LibUA.Core
Public Class OPCClient
Inherits Client
Public Sub New(ByVal Target As String, ByVal Port As Integer, ByVal Timeout As Integer)
MyBase.New(Target, Port, Timeout)
End Sub
Public Overrides Sub NotifyDataChangeNotifications(subscriptionId As UInteger, clientHandles As UInteger(), notifications As DataValue())
For i = 0 To clientHandles.Length - 1
Log(String.Format("subscrId {0} handle {1}: {2}", subscriptionId, clientHandles(i), notifications(i).Value.ToString()))
Next
End Sub
End Class
Hi, I put common (Core & Framework) in shared project.
I let just security.cs separated, it have many differences. Maby if some one understund it better, can make it better.
Ladislav
duplicate line in method HandleReadRequest
readValueIds[i].AttributeId == NodeAttribute.UserWriteMask
I've just got the following error(s):
CS0104 "RSACng" is an ambiguous reference between "LibUA.Security.Cryptography.RSACng" and "System.Security.Cryptography.RSACng". LibUA c:@d\Dev\OPC-UA\LibUA-master\NET\LibUA\Security.cs 399
It relates to statement
var rsa = new RSACng();
in function ImportRSAPrivateKey() and ImportRSAPublicKey().
Looking at the counterpart in NET Core, there is the statement
var rsa = new RSACryptoServiceProvider();
By replacing the error causing lines with the corresponding lines from NET Core the errors disappear.
I cannot decide whether the content of this change is correct.
Afterwards new errors in projects TestClient, Testserver appear, same reason.
It relates to statement
var certPrivateCNG = new RSACng(appCertificate.GetCngPrivateKey());
The counterpart in NET Core seems to be on a complete other way.
So I replaced the error causing statement with
var certPrivateCNG = new LibUA.Security.Cryptography.RSACng(appCertificate.GetCngPrivateKey());
I cannot decide whether the content of this change is correct.
(This kind of change could also have been made in project LibUA)
ralf
Thanks for the development of this library, this was very useful for the development of an OPC UA client to connect a S7-1500 PLC with MessageSecurityMode.None with username and password.
Unfortunately there was one bug that took me some time to figure out why the ActivateSession call was not accepted by the server.
Finally I found there was something wrong with the encryption of the password.
After doing the change below the ActivateSession was accepted by the server.
I am not sure if this is affecting any other ActivateSession with different policies, but for me this is working.
Maybe you can apply this change to the git library?
LibUA/NET/LibUA/Client.cs
original:
if (config.RemoteNonce != null)
{
Array.Copy(config.RemoteNonce, 0, crypted, offset, config.RemoteNonce.Length);
offset += config.RemoteNonce.Length;
}
Array.Copy(rndBytes, 0, crypted, offset, rndBytes.Length);
offset += rndBytes.Length;
After edit:
if (config.RemoteNonce != null)
{
Array.Copy(config.RemoteNonce, 0, crypted, offset, config.RemoteNonce.Length);
offset += config.RemoteNonce.Length;
}
else
{
Array.Copy(rndBytes, 0, crypted, offset, rndBytes.Length);
offset += rndBytes.Length;
}
Hello,
What I would need in my company's industrial application is a possibility to use user authentication by certificate in .NET application and what I saw in your code there are only anonymous or username connection available:
Client.cs - row 1665:
else
{
throw new Exception(string.Format("Identity token of type {0} is not supported", identityToken.GetType().ToString()));
}
Could it be possible for you to implement this feature?
Hi, I'm able to read successfully but when I try to write I get response status 2155020288.
This is the snippet I use:
uint[] respStatuses;
// send the program number, for this example the program number is 32
client.Write(new WriteValue[]
{
new WriteValue(
new NodeId(4, "swRemRecipe1"), NodeAttribute.Value,
null, new DataValue(32, StatusCode.GoodClamped, DateTime.Now))
}, out respStatuses);
// set the status flag to 1
client.Write(new WriteValue[]
{
new WriteValue(
new NodeId(4, "swRemNewRecipe1"), NodeAttribute.Value,
null, new DataValue(1, StatusCode.GoodClamped, DateTime.Now))
}, out respStatuses);
Console.WriteLine($"response status {respStatuses[0]}");
Attached there are 2 capture files, one made with UAExpert where I successfully set the variables and the second one with my TestOPC program where, after some readings, I try to set the variable with no luck. The response status is 2155020288.
Could you pls. help me.
Thanks
Downloads.zip
The standard server certificate from libua demo server is missing some properties, e.g.:
X509v3 Basic Constraints, X509v3 Key Usage, X509v3 Extended Key Usage, X509v3 Subject Alternative Name.
I added a more conform DER encoded certificate (marked as usable for uaclient and uaserver, but uaserver should better a certificate marked as usable for server and uaclients should better use a certificate marked as usable for clients) and a certificate template for the XCA tool.
Hi
Thank you very much for your client / server implementations, I like them a lot!
I am actually learning OPC-UA, so this may be a basic question. I tried your server and connected with UA Expert (v1.5.1.331). Everything seems to work fine, however I get this error a lot in the logs:
Error: Number of acknowledgement results (0) does not match number of acknowledgements(1)
Do you know whats the issue there?
So I was trying to create a new method in the server just like:
`NodeMethod method = new NodeMethod(new NodeId(2, "Trigger"),
new QualifiedName("Trigger"), new LocalizedText("Trigger"),
new LocalizedText("Trigger"), 0, 0, true, true);
ItemsRoot.References.Add(new ReferenceNode(new NodeId(UAConst.Organizes), method.Id, false));
method.References.Add(new ReferenceNode(new NodeId(UAConst.Organizes), ItemsRoot.Id, true));
AddressSpaceTable.TryAdd(method.Id, method);`
and it is added without a problem.
However, I could not find a way to customize what happens when the method is invoked...
Can someone help me?
Thanks
Hi,
many thanks for this library, it seems to be exactly what I need to develop simple client for data exchange with PLC running OPC server. A simple dll with all the required functionality. When using anonymous server access, everything works as expected (apart some TODO exceptions here and there, which I don't need anyway). However I have one problem regarding session with UserTokenType.UserName - is this implemented?
The user with password is defined on OPC server, there is an endpoint without security (MessageSecurity.None, SecurityPolicy.None) and UserTokenPolicy "Username". Every function in connection sequence return StatusCode Good including ActivateSession:
client.Connect();
client.OpenSecureChannel(MessageSecurityMode.None, SecurityPolicy.None, srv_cert);
var appDesc = new ApplicationDescription("urn:qs:TestClient", "uri:qs:TestClient",
new LocalizedText("OPC Test Client"), ApplicationType.Client, null, null, null);
client.CreateSession(appDesc, "urn:qs:TestClient", 120);
string username = textBoxUser.Text;
byte[] password = (new System.Text.UTF8Encoding()).GetBytes(textBoxPass.Text);
object usr_identity = new UserIdentityUsernameToken(srv_policy, username, password, Types.SignatureAlgorithmRsa15);
client.ActivateSession(usr_identity, new[] { "en" });
Variables srv_cert (correct array of bytes) and srv_policy ("1" matching the UserTokenPolicy "Username") are loaded before the Connect function from server using your example client code. Weird thing is the ActivateSession returns Good even when the username/password is wrong or missing. I looked into the source code of ActivateSession and found no handler for StatusCode.BadUserAccessDenied. Any attempt to browse nodes using function Browse in this "Good" session ends with exception about array dimensions. The Browse function tries to create an array with impossible length in numRefDesc right after the server response:
refDescs = new ReferenceDescription[numRefDesc];
I then tried to connect to the server with free Prosys OPC UA client application and for username/password access it worked as expected - wrong user was rejected, correct one was allowed. But I don't have sources for the client to look at obviously.
One more thing - I also tried latest official OPC UA stack from OPCFoundation here on GitHub, compiled the client example and upon connection with the same access as in the Prosys client and my client it ended with 5 exception about security, so it cannot connect to the server with those official libraries too, so I am at lost here as in the Prosys client it somehow worked...
A declarative, efficient, and flexible JavaScript library for building user interfaces.
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google ❤️ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.