OPC Studio User's Guide and Reference
GetCertificateStatus Method (_EasyUACertificateManagementClient)
Example 



View with Navigation Tools
OpcLabs.EasyOpcUA Assembly > OpcLabs.EasyOpc.UA.Gds.ComTypes Namespace > _EasyUACertificateManagementClient Interface : GetCertificateStatus Method
Endpoint descriptor. Identifies the OPC-UA server. The server must be a Global Directory Server (GDS).
The identifier assigned to the Application Instance by the GDS.
The NodeId of the Certificate Group which provides the context.
If OpcLabs.EasyOpc.UA.AddressSpace.UANodeId.Null the CertificateManager shall choose the DefaultApplicationGroup.
The NodeId of the CertificateType for the Certificate.
If OpcLabs.EasyOpc.UA.AddressSpace.UANodeId.Null the CertificateManager shall select a Certificate based on the value of the certificateGroupId argument.
Checks if an application needs to update its certificate.
Syntax
'Declaration
 
Function GetCertificateStatus( _
   ByVal gdsEndpointDescriptor As Object, _
   ByVal applicationId As Object, _
   ByVal certificateGroupId As Object, _
   ByVal certificateTypeId As Object _
) As Boolean
 
'Usage
 
Dim instance As _EasyUACertificateManagementClient
Dim gdsEndpointDescriptor As Object
Dim applicationId As Object
Dim certificateGroupId As Object
Dim certificateTypeId As Object
Dim value As Boolean
 
value = instance.GetCertificateStatus(gdsEndpointDescriptor, applicationId, certificateGroupId, certificateTypeId)

Parameters

gdsEndpointDescriptor
Endpoint descriptor. Identifies the OPC-UA server. The server must be a Global Directory Server (GDS).
applicationId
The identifier assigned to the Application Instance by the GDS.
certificateGroupId
The NodeId of the Certificate Group which provides the context.
If OpcLabs.EasyOpc.UA.AddressSpace.UANodeId.Null the CertificateManager shall choose the DefaultApplicationGroup.
certificateTypeId
The NodeId of the CertificateType for the Certificate.
If OpcLabs.EasyOpc.UA.AddressSpace.UANodeId.Null the CertificateManager shall select a Certificate based on the value of the certificateGroupId argument.

Return Value

Returns true if the Application needs to request a new Certificate from the GDS.
Returns false if the Application can keep using the existing Certificate.
Exceptions
ExceptionDescription

A null reference (Nothing in Visual Basic) is passed to a method that does not accept it as a valid argument.

This is a usage error, i.e. it will never occur (the exception will not be thrown) in a correctly written program. Your code should not catch this exception.

The OPC UA operation has failed. This operation exception in uniformly used to allow common handling of various kinds of errors. The System.Exception.InnerException always contains information about the actual error cause.

This is an operation error that depends on factors external to your program, and thus cannot be always avoided. Your code must handle it appropriately.

Example

.NET

COM

// 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 .

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
    }
}
// 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 .

class procedure GetCertificateStatus.Main;
var
  Application: TEasyUAApplication;
  ApplicationId: _UANodeId;
  CertificateManagementClient: OpcLabs_EasyOpcUA_TLB._EasyUACertificateManagementClient;
  GdsEndpointDescriptor: _UAEndpointDescriptor;
  NullNodeId: _UANodeId;
  UpdateRequired: boolean;
begin
  // Define which GDS we will work with.
  GdsEndpointDescriptor := CoUAEndpointDescriptor.Create;
  GdsEndpointDescriptor.UrlString := 'opc.tcp://opcua.demo-this.com:58810/GlobalDiscoveryServer';
  GdsEndpointDescriptor.UserIdentity.UserNameTokenInfo.UserName := 'appadmin';
  GdsEndpointDescriptor.UserIdentity.UserNameTokenInfo.Password := 'demo';

  // Register our client application with the GDS, so that we obtain an application ID that we need later.
  // Obtain the application interface.
  Application := TEasyUAApplication.Create(nil);

  // Create an application registration in the GDS, assigning it a new application ID.
  try
    ApplicationId := Application.RegisterToGds(GdsEndpointDescriptor);
  except
    on E: EOleException do
    begin
      WriteLn(Format('*** Failure: %s', [E.GetBaseException.Message]));
    end;
  end;

  WriteLn('Application ID: ', ApplicationId.ToString);

  // Instantiate the certificate management client object
  CertificateManagementClient := CoEasyUACertificateManagementClient.Create;

  // Check if the application needs to update its certificate.
  NullNodeId := CoUANodeId.Create;
  UpdateRequired := false;
  try
    UpdateRequired := CertificateManagementClient.GetCertificateStatus(GdsEndpointDescriptor, ApplicationId, NullNodeId, NullNodeId);
  except
    on E: EOleException do
    begin
      WriteLn(Format('*** Failure: %s', [E.GetBaseException.Message]));
    end;
  end;

  // Display results
  WriteLn('Update required: ', UpdateRequired);

  // Example output:
  //Application ID: nsu=http://opcfoundation.org/UA/GDS/applications/ ;ns=2;g=aec94459-f513-4979-8619-8383555fca61
  //Update required: FALSE

end;
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