QuickOPC User's Guide and Reference
HttpsCertificateAcceptancePolicy Property (_UASmartEngineParameters)
Example 



OpcLabs.EasyOpcUA Assembly > OpcLabs.EasyOpc.UA.Engine.ComTypes Namespace > _UASmartEngineParameters Interface : HttpsCertificateAcceptancePolicy Property
Determines which HTTPS server certificates are accepted.
Syntax
'Declaration
 
<CanBeNullAttribute()>
Property HttpsCertificateAcceptancePolicy As UACertificateAcceptancePolicy
'Usage
 
Dim instance As _UASmartEngineParameters
Dim value As UACertificateAcceptancePolicy
 
instance.HttpsCertificateAcceptancePolicy = value
 
value = instance.HttpsCertificateAcceptancePolicy
[CanBeNull()]
UACertificateAcceptancePolicy HttpsCertificateAcceptancePolicy {get; set;}
[CanBeNull()]
property UACertificateAcceptancePolicy^ HttpsCertificateAcceptancePolicy {
   UACertificateAcceptancePolicy^ get();
   void set (    UACertificateAcceptancePolicy^ value);
}
Remarks

When this is null, the policy given by OpcLabs.BaseLib.Security.CertificateAcceptancePolicy is used. This causes the same rules be used for HTTPS server certificates as for server instance certificates.

In order to obtain or modify this parameter, access the OpcLabs.EasyOpc.UA.Engine.EasyUASharedParameters.EngineParameters property of static OpcLabs.EasyOpc.UA.EasyUAClientCore.SharedParameters.

This method or property does not throw any exceptions, aside from execution exceptions such as System.Threading.ThreadAbortException or System.OutOfMemoryException.

Example

.NET

COM

// This example shows how in a console application, the user is asked to accept a server HTTPS certificate.

using System;
using OpcLabs.EasyOpc.UA;
using OpcLabs.EasyOpc.UA.OperationModel;

namespace UADocExamples.Interaction
{
    partial class AcceptCertificate
    {
        public static void Https()
        {
            // Do not implicitly trust any endpoint URLs. We want the user be asked explicitly.
            EasyUAClient.SharedParameters.EngineParameters.CertificateAcceptancePolicy.TrustedEndpointUrlStrings.Clear();

            // Define which server we will work with.
            UAEndpointDescriptor endpointDescriptor = "https://opcua.demo-this.com:51212/UA/SampleServer/";
            
            // Instantiate the client object.
            var client = new EasyUAClient();

            UAAttributeData attributeData;
            try
            {
                // Obtain attribute data.
                // The component automatically triggers the necessary user interaction during the first operation.
                attributeData = client.Read(endpointDescriptor, "nsu=http://test.org/UA/Data/ ;i=10853");
            }
            catch (UAException uaException)
            {
                Console.WriteLine("*** Failure: {0}", uaException.GetBaseException().Message);
                return;
            }

            // Display results.
            Console.WriteLine("Value: {0}", attributeData.Value);
            Console.WriteLine("ServerTimestamp: {0}", attributeData.ServerTimestamp);
            Console.WriteLine("SourceTimestamp: {0}", attributeData.SourceTimestamp);
            Console.WriteLine("StatusCode: {0}", attributeData.StatusCode);
        }
    }
}
# This example shows how in a console application, the user is asked to accept a server HTTPS certificate.

# The QuickOPC package is needed. Install it using "pip install opclabs_quickopc".
import opclabs_quickopc

# Import .NET namespaces.
from OpcLabs.EasyOpc.UA import *
from OpcLabs.EasyOpc.UA.OperationModel import *


# Do not implicitly trust any endpoint URLs. We want the user be asked explicitly.
EasyUAClient.SharedParameters.EngineParameters.CertificateAcceptancePolicy.TrustedEndpointUrlStrings.Clear()

# Define which server we will work with.
endpointDescriptor = UAEndpointDescriptor('https://opcua.demo-this.com:51212/UA/SampleServer/')

# Instantiate the client object.
client = EasyUAClient()

try:
    # Obtain attribute data.
    # The component automatically triggers the necessary user interaction during the first operation.
    attributeData = IEasyUAClientExtension.Read(client,
                                                endpointDescriptor,
                                                UANodeDescriptor('nsu=http://test.org/UA/Data/ ;i=10853'))
except UAException as uaException:
    print('*** Failure: ' + uaException.GetBaseException().Message)
    exit()

# Display results.
print('Value: ', attributeData.Value)
print('ServerTimestamp: ', attributeData.ServerTimestamp)
print('SourceTimestamp: ', attributeData.SourceTimestamp)
print('StatusCode: ', attributeData.StatusCode)

print()
print('Finished.')
' This example shows how in a console application, the user is asked to accept a server HTTPS certificate.

Imports OpcLabs.EasyOpc.UA
Imports OpcLabs.EasyOpc.UA.OperationModel

Namespace Interaction
    Partial Friend Class AcceptCertificate
        Public Shared Sub Https()

            ' Do not implicitly trust any endpoint URLs. We want the user be asked explicitly.
            EasyUAClient.SharedParameters.EngineParameters.CertificateAcceptancePolicy.TrustedEndpointUrlStrings.Clear()

            ' Define which server we will work with.
            Dim endpointDescriptor As UAEndpointDescriptor = "https://opcua.demo-this.com:51212/UA/SampleServer/"

            ' Instantiate the client object.
            Dim client = New EasyUAClient()

            Dim attributeData As UAAttributeData
            Try
                ' Obtain attribute data.
                ' The component automatically triggers the necessary user interaction during the first operation.
                attributeData = client.Read(endpointDescriptor, "nsu=http://test.org/UA/Data/ ;i=10853")
            Catch uaException As UAException
                Console.WriteLine("*** Failure: {0}", uaException.GetBaseException.Message)
                Exit Sub
            End Try

            ' Display results.
            Console.WriteLine("Value: {0}", attributeData.Value)
            Console.WriteLine("ServerTimestamp: {0}", attributeData.ServerTimestamp)
            Console.WriteLine("SourceTimestamp: {0}", attributeData.SourceTimestamp)
            Console.WriteLine("StatusCode: {0}", attributeData.StatusCode)
        End Sub
    End Class
End Namespace
// This example shows how in a console application, the user is asked to accept a server HTTPS certificate.

class procedure AcceptCertificate.Https;
var
  AttributeData: _UAAttributeData;
  Client: OpcLabs_EasyOpcUA_TLB._EasyUAClient;
  ClientManagement: TEasyUAClientManagement;
  EndpointDescriptor: string;
begin
  // The configuration object allows access to static behavior.
  ClientManagement := TEasyUAClientManagement.Create(nil);
  ClientManagement.Connect;

  // Do not implicitly trust any endpoint URLs. We want the user be asked explicitly.
  ClientManagement.SharedParameters.EngineParameters.CertificateAcceptancePolicy.TrustedEndpointUrlStrings.Clear();

  // Define which server we will work with.
  EndpointDescriptor := 'https://opcua.demo-this.com:51212/UA/SampleServer/';

  // Instantiate the client object.
  Client := CoEasyUAClient.Create;
  try
    // Obtain attribute data.
    // The component automatically triggers the necessary user interaction during the first operation.
    AttributeData := Client.Read(EndpointDescriptor, 'nsu=http://test.org/UA/Data/ ;i=10853');
  except
    on E: EOleException do
    begin
      WriteLn(Format('*** Failure: %s', [E.GetBaseException.Message]));
      Exit;
    end;
  end;

  // Display results.
  WriteLn('Value: ', AttributeData.Value);
  WriteLn('ServerTimestamp: ', DateTimeToStr(AttributeData.ServerTimestamp));
  WriteLn('SourceTimestamp: ', DateTimeToStr(AttributeData.SourceTimestamp));
  WriteLn('StatusCode: ', AttributeData.StatusCode.ToString);

  FreeAndNil(ClientManagement);
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