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



View with Navigation Tools
OpcLabs.EasyOpcUA Assembly > OpcLabs.EasyOpc.UA.Gds Namespace : IEasyUACertificateManagementClient Interface
Provides access to certificate management (CM) information model of an OPC UA Global Discovery Server (GDS).
Syntax
'Declaration
 
<ComVisibleAttribute(False)>
<ExceptionContractAnnotationAttribute(True)>
<ExceptionContractVerificationAttribute(True)>
Public Interface IEasyUACertificateManagementClient 
   Inherits IEasyUACertificateManagement, OpcLabs.EasyOpc.UA.IEasyUASpecializedClient, System.IServiceProvider 
 
'Usage
 
Dim instance As IEasyUACertificateManagementClient
Remarks

This interface contains methods to communicate with the OPC UA Global Discovery Server (GDS) using its information model for certificate management, making the work of assembling the proper OPC UA method parameters and retrieving the results. The methods allow getting certificate groups, requesting key pairs or certificate signing and obtaining the results, retrieving trust lists, and more.

In the OPC UA specifications, the functionality covered by this type is described in Part 12: Discovery and Global Services, in the section Certificate Management Overview.

You can obtain this interface e.g.:

Before deciding to use methods provided by this specialized client, it is recommended that you have a look at the OpcLabs.EasyOpc.UA.Application.IEasyUAClientServerApplication service, available from System.IServiceProvider.GetService(System.Type) method from the OpcLabs.EasyOpc.UA.IEasyUAClient interface. The client application service works on higher level, and conveniently combines several methods together to achieve the typically needed functionality related to GDS and certificate management in OPC UA.

 

The OPC UA Certificate Management Client is a specialized OPC UA client object providing access to certificate management (CM) information model of an OPC UA Global Discovery Server (GDS). In the OPC UA specifications, the functionality covered by this type is described in Part 12: Discovery and Global Services, in the section Certificate Management Overview.

This specialized client object can be derived from IEasyUAClient Interface using the AsCertificateManagementClient Extension Method, or it can be created standalone as EasyUACertificateManagementClient Component.

This interface contains methods to communicate with the OPC UA Global Discovery Server (GDS) using its information model for certificate management, making the work of assembling the proper OPC UA method parameters and retrieving the results. The methods allow getting certificate groups, requesting key pairs or certificate signing and obtaining the results, retrieving trust lists, and more.

Before deciding to use methods provided by this specialized client, it is recommended that you have a look at the IEasyUAClientServerApplication service (see OPC UA Client-Server Application Service), available from IServiceProvider.GetService method from the IEasyUAClient interface. The client application service works on even a higher level, and conveniently combines several methods together to achieve the typically needed functionality related to GDS and certificate management in OPC UA.

Available methods are:

There are also helper classes are available that relate to certificate management:

 

The features discussed here, or some of them, may not be available in all editions of the product. Check the QuickOPC Product Editions page for differences between the editions. The trial license has all features enabled (and is limited in period for which it provides valid data), but licenses for specific commercial editions may have functionality limitations.

 

Example
// Shows how to check if an application needs to update its certificate.
//
// 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.AddressSpace;
using OpcLabs.EasyOpc.UA.Application;
using OpcLabs.EasyOpc.UA.Extensions;
using OpcLabs.EasyOpc.UA.Gds;
using OpcLabs.EasyOpc.UA.OperationModel;

namespace UADocExamples.Gds._EasyUACertificateManagementClient
{
    class GetCertificateStatus
    {
        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");

            // Register our client application with the GDS, so that we obtain an application ID that we need later.
            // Obtain the application interface.
            EasyUAApplication application = EasyUAApplication.Instance;
            UANodeId applicationId;
            try
            {
                applicationId = application.RegisterToGds(gdsEndpointDescriptor);
            }
            catch (UAException uaException)
            {
                Console.WriteLine("*** Failure: {0}", uaException.GetBaseException().Message);
                return;
            }
            Console.WriteLine("Application ID: {0}", applicationId);

            // Instantiate the certificate management client object
            var certificateManagementClient = new EasyUACertificateManagementClient();

            // Check if the application needs to update its certificate.
            bool updateRequired;
            try
            {
                updateRequired = certificateManagementClient.GetCertificateStatus(gdsEndpointDescriptor, applicationId,
                    UANodeId.Null, UANodeId.Null);
            }
            catch (UAException uaException)
            {
                Console.WriteLine("*** Failure: {0}", uaException.GetBaseException().Message);
                return;
            }

            // Display results
            Console.WriteLine("Update required: {0}", updateRequired);
        }


        // Example output:
        //Application ID: nsu=http://opcfoundation.org/UA/GDS/applications/ ;ns=2;g=aec94459-f513-4979-8619-8383555fca61
        //Update required: False
    }
}
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