OPC Studio User's Guide and Reference
IEasyUAClientServerApplication Interface
Members  Example 



View with Navigation Tools
OpcLabs.EasyOpcUA Assembly > OpcLabs.EasyOpc.UA.Application Namespace : IEasyUAClientServerApplication Interface
Allows management of the OPC UA client or server application.
Object Model
IEasyUAClientServerApplication InterfaceIPkiApplicationStoreGroup InterfaceCertificateGenerationParameters ClassUACertificateRequestParameters ClassUANodeId ClassStringCollection ClassUANodeIdCollection ClassUANodeId Class
Syntax
'Declaration
 
<ComVisibleAttribute(False)>
<ExceptionContractAnnotationAttribute(True)>
<CLSCompliantAttribute(True)>
Public Interface IEasyUAClientServerApplication 
   Inherits OpcLabs.BaseLib.ComponentModel.IEventLocking, System.IDisposable, System.IServiceProvider 
 
'Usage
 
Dim instance As IEasyUAClientServerApplication
Remarks

This service has high-level properties and methods for tasks related to maintaining application registrations in the GDS servers, obtaining own certificate from GDS, refreshing application trust lists from GDS, etc.

You can obtain this interface by calling System.IServiceProvider.GetService(System.Type) on the OpcLabs.EasyOpc.UA.IEasyUAClient with the type of IEasyUAClientServerApplication as an argument. In COM, use the OpcLabs.EasyOpc.UA.ComTypes._EasyUAClient.GetServiceByName method instead.

Example
// Shows how to obtain a new application certificate pack from the certificate manager (GDS), and store it for subsequent
// usage.
//
// Find all latest examples here: https://opclabs.doc-that.com/files/onlinedocs/OPCLabs-OpcStudio/Latest/examples.html .
// OPC client and subscriber examples in C# on GitHub: https://github.com/OPCLabs/Examples-QuickOPC-CSharp .
// Missing some example? Ask us for it on our Online Forums, https://www.opclabs.com/forum/index ! You do not have to own
// a commercial license in order to use Online Forums, and we reply to every post.

using System;
using System.Collections.Generic;
using OpcLabs.BaseLib.Security.Cryptography.PkiCertificates;
using OpcLabs.EasyOpc.UA;
using OpcLabs.EasyOpc.UA.AddressSpace;
using OpcLabs.EasyOpc.UA.Application;
using OpcLabs.EasyOpc.UA.Application.Extensions;
using OpcLabs.EasyOpc.UA.Extensions;
using OpcLabs.EasyOpc.UA.OperationModel;

namespace UADocExamples.Application._IEasyUAClientServerApplication
{
    partial class ObtainNewCertificatePack
    {
        public static void Main1()
        {
            // Define which GDS we will work with.
            UAEndpointDescriptor gdsEndpointDescriptor =
                ((UAEndpointDescriptor)"opc.tcp://opcua.demo-this.com:58810/GlobalDiscoveryServer")
                .WithUserNameIdentity("appadmin", "demo");

            // Obtain the application interface.
            EasyUAApplication application = EasyUAApplication.Instance;

            // Display which application we are about to work with.
            Console.WriteLine("Application URI string: {0}",
                application.GetApplicationElement().ApplicationUriString);
            
            // Obtain a new application certificate pack from the certificate manager (GDS), and store it for subsequent
            // usage.
            UANodeIdPkiCertificateDictionary certificateDictionary;
            try
            {
                certificateDictionary = application.ObtainNewCertificatePack(gdsEndpointDescriptor);
            }
            catch (UAException uaException)
            {
                Console.WriteLine("*** Failure: {0}", uaException.GetBaseException().Message);
                return;
            }

            // Display results
            foreach (KeyValuePair<UANodeId, IPkiCertificate> pair in certificateDictionary)
            {
                Console.WriteLine();
                Console.WriteLine($"Certificate type Id: {pair.Key}");
                Console.WriteLine($"Certificate: {pair.Value}");
            }
        }
    }
}
// Shows how to refresh own certificate stores using current trust lists for the application from the certificate manager.
//
// Find all latest examples here: https://opclabs.doc-that.com/files/onlinedocs/OPCLabs-OpcStudio/Latest/examples.html .
// OPC client and subscriber examples in C# on GitHub: https://github.com/OPCLabs/Examples-QuickOPC-CSharp .
// Missing some example? Ask us for it on our Online Forums, https://www.opclabs.com/forum/index ! You do not have to own
// a commercial license in order to use Online Forums, and we reply to every post.

using System;
using OpcLabs.EasyOpc.UA;
using OpcLabs.EasyOpc.UA.Application;
using OpcLabs.EasyOpc.UA.Application.Extensions;
using OpcLabs.EasyOpc.UA.Extensions;
using OpcLabs.EasyOpc.UA.Gds;
using OpcLabs.EasyOpc.UA.OperationModel;

namespace UADocExamples.Application._IEasyUAClientServerApplication
{
    class RefreshTrustLists
    {
        public static void Main1()
        {
            // Define which GDS we will work with.
            UAEndpointDescriptor gdsEndpointDescriptor =
                ((UAEndpointDescriptor)"opc.tcp://opcua.demo-this.com:58810/GlobalDiscoveryServer")
                .WithUserNameIdentity("appadmin", "demo");

            // Obtain the application interface.
            EasyUAApplication application = EasyUAApplication.Instance;

            // Display which application we are about to work with.
            Console.WriteLine("Application URI string: {0}",
                application.GetApplicationElement().ApplicationUriString);

            // Refresh own certificate stores using current trust lists for the application from the certificate manager.
            UATrustListMasks refreshedTrustLists;
            try
            {
                refreshedTrustLists = application.RefreshTrustLists(gdsEndpointDescriptor);
            }
            catch (UAException uaException)
            {
                Console.WriteLine("*** Failure: {0}", uaException.GetBaseException().Message);
                return;
            }

            // Display results
            Console.WriteLine("Refreshed trust lists: {0}", refreshedTrustLists);
        }
    }
}
Requirements

Target Platforms: .NET Framework: Windows 10 (selected versions), Windows 11 (selected versions), Windows Server 2016, Windows Server 2022; .NET: Linux, macOS, Microsoft Windows

See Also