You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I know CoreClientUtils SelectEndpoint can return the safest EndpointDescription, but I want to create a EndpointDescription, testing different Endpoint security policy, but it can't work;
I found CoreClientUtils SelectEndpoint the certificate is not the same as I create EndpointDescription certificate, unable to realize the connection;
I trust a certificate on the server side, can't I connect with this client certificate?
private EndpointDescription CreateEndpointDescription(ApplicationConfiguration configuration, string url, string secPolicy, MessageSecurityMode msgSecMode)
{
EndpointDescription endpointDescription = new EndpointDescription();
endpointDescription.EndpointUrl = url;
endpointDescription.SecurityPolicyUri = SecurityPolicies.GetUri(secPolicy);
endpointDescription.SecurityMode = msgSecMode;
endpointDescription.SecurityLevel = ServerSecurityPolicy.CalculateSecurityLevel(msgSecMode, SecurityPolicies.GetUri(secPolicy));
var tokenPolicy = new UserTokenPolicy(UserTokenType.UserName);
tokenPolicy.SecurityPolicyUri = SecurityPolicies.GetUri(secPolicy);
endpointDescription.UserIdentityTokens.Add(tokenPolicy);
endpointDescription.TransportProfileUri = Profiles.UaTcpTransport;
if (secPolicy != SecurityPolicies.None)
{
var InstanceCertificate = configuration.SecurityConfiguration.ApplicationCertificate.Find(true).Result;
endpointDescription.ServerCertificate = InstanceCertificate.RawData;
}
return endpointDescription;
}
public async void Connect(string url, string secPolicy, MessageSecurityMode msgSecMode, bool userAuth, string userName, string password)
{
try
{
//Secify application configuration
ApplicationConfiguration ApplicationConfig = mApplicationConfig;
//Create EndPoint description
EndpointDescription EndpointDescription = CreateEndpointDescription(ApplicationConfig, url, secPolicy, MessageSecurityMode.SignAndEncrypt);
//Create EndPoint configuration
EndpointConfiguration EndpointConfiguration = EndpointConfiguration.Create(ApplicationConfig);
//Create an Endpoint object to connect to server
ConfiguredEndpoint Endpoint = new ConfiguredEndpoint(null, EndpointDescription, EndpointConfiguration);
//Create anonymous user identity
UserIdentity UserIdentity;
if (userAuth)
{
UserIdentity = new UserIdentity(userName,password);
}
else
{
UserIdentity = new UserIdentity();
}
ApplicationConfig.CertificateValidator.Update(ApplicationConfig);
mSession = await Session.Create(
mApplicationConfig,
Endpoint,
false,
false,
ApplicationConfig.ApplicationName,
6000,
UserIdentity,
new string[] { });
}
catch (Exception e)
{
//handle Exception here
}
}
Expected Behavior
No response
Steps To Reproduce
No response
Environment
OS:window10
Environment: Visual Studio 2022
Runtime: .NET 8.0
Nuget Version:OPCFoundation.NetStandard.Opc.Ua(1.5.374.126)
Server: Prosys OPC UA Simulation Server
Anything else?
No response
The text was updated successfully, but these errors were encountered:
mregen
changed the title
<title>
How to connect using a custom endpoint
Dec 13, 2024
mregen
added
the
question
The issue contains a question. After no activity the issue might be closed.
label
Dec 13, 2024
Type of issue
Current Behavior
I know CoreClientUtils SelectEndpoint can return the safest EndpointDescription, but I want to create a EndpointDescription, testing different Endpoint security policy, but it can't work;
I found CoreClientUtils SelectEndpoint the certificate is not the same as I create EndpointDescription certificate, unable to realize the connection;
I trust a certificate on the server side, can't I connect with this client certificate?
Expected Behavior
No response
Steps To Reproduce
No response
Environment
Anything else?
No response
The text was updated successfully, but these errors were encountered: