// This example shows how in a console application, the user is asked to allow a server instance certificate with
// mismatched domain name.
using System;
using OpcLabs.EasyOpc.UA;
using OpcLabs.EasyOpc.UA.OperationModel;
namespace UADocExamples.Interaction
{
class AllowEndpointDomain
{
public static void Main1()
{
// Define which server we will work with.
// Note that extra '.' at the end of the domain name. For the purpose of this example, it allows us to address
// the same domain, but cause a mismatch with what the names that are listed in the server instance certificate.
UAEndpointDescriptor endpointDescriptor = "opc.tcp://opcua.demo-this.com.:51210/UA/SampleServer";
// Instantiate the client object.
var client = new EasyUAClient()
{
// Enforce the endpoint domain check.
Isolated = true,
IsolatedParameters = {SessionParameters = {CheckEndpointDomain = true}}
};
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 allow a server instance certificate with
# mismatched domain name.
# 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 *
# Define which server we will work with.
# Note that extra '.' at the end of the domain name. For the purpose of this example, it allows us to address
# the same domain, but cause a mismatch with what the names that are listed in the server instance certificate.
endpointDescriptor = UAEndpointDescriptor('opc.tcp://opcua.demo-this.com.:51210/UA/SampleServer')
# Instantiate the client object.
client = EasyUAClient()
# Enforce the endpoint domain check.
client.Isolated = True
client.IsolatedParameters.SessionParameters.CheckEndpointDomain = True
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 allow a server instance certificate with
' mismatched domain name.
Imports OpcLabs.EasyOpc.UA
Imports OpcLabs.EasyOpc.UA.OperationModel
Imports OpcLabs.EasyOpc.UA.Engine
Namespace Interaction
Friend Class AllowEndpointDomain
Public Shared Sub Main1()
' Define which server we will work with.
' Note that extra '.' at the end of the domain name. For the purpose of this example, it allows us to address
' the same domain, but cause a mismatch with what the names that are listed in the server instance certificate.
Dim endpointDescriptor As UAEndpointDescriptor = "opc.tcp://opcua.demo-this.com.:51210/UA/SampleServer"
' Instantiate the client object.
Dim client = New EasyUAClient() With _
{ _
.Isolated = True, _
.IsolatedParameters = New EasyUAAdaptableParameters() With _
{ _
.SessionParameters = New UASmartSessionParameters() With _
{ _
.CheckEndpointDomain = True _
} _
} _
}
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