Could not send an open secure channel request on connect

Questions regarding the use of the .NET SDK 2.0 for Server or Client development or integration into customer products ...

Moderator: uasdknet

Post Reply
chauser
Jr. Member
Jr. Member
Posts: 1
Joined: 12 Nov 2015, 13:56

Could not send an open secure channel request on connect

Post by chauser »

Hello,

I want to connect to a OPC UA Server via the Connect Method.

I am using the following code:

Code: Select all

 EndpointDescription endpointDescription = new Discovery().GetMostSecureEndpoint(paramEndpoint);

                //SecurityMode
                switch (securityMode)
                {
                    case "None":
                        endpointDescription.SecurityMode = MessageSecurityMode.None;
                        break;
                    case "Sign":
                        endpointDescription.SecurityMode = MessageSecurityMode.Sign;
                        break;
                    case "SignAndEncrypt":
                        endpointDescription.SecurityMode = MessageSecurityMode.SignAndEncrypt;
                        break;
                }

                //SecurityPolicy
                endpointDescription.SecurityPolicyUri = @"http://opcfoundation.org/UA/SecurityPolicy#" + securityPolicy;
                endpointDescription.TransportProfileUri = "http://opcfoundation.org/UA-Profile/Transport/uatcp-uasc-uabinary";

                if (currentSession == null)
                {
                    string key = "..."; //my licence key
                    byte[] keyArray = GetBytes(key);

                    ICertificate certificate = new Certificate(keyArray);

                    localSession.Application.AddCertificateToTrustList(certificate);
                    localSession.Application.ApplicationCertificate = certificate;
                    localSession.UserIdentity = new UserIdentity();
                    localSession.UserIdentity.Certificate = certificate;            
                }

                localSession.SessionName = paramSessionName;
                localSession.Connect(endpointDescription.EndpointUrl, SecuritySelection.BestAvailable);
When i set the security policy and the security mode to "None" then there is now licence needed for the connection.
But when I am using the licence for the certification as I do and set a new policy and mode, I get the exception: "Could not send an open secure channel request"

Can some one tell me, what I am doing wrong here ?

When starting my client I also setup the licence file via:

Code: Select all

ApplicationLicenseManager.AddProcessLicenses(System.Reflection.Assembly.GetExecutingAssembly(), "license.lic");
Greetings

chauser

Post Reply