// This example demonstrates how to place the client certificate in the platform-specific (Windows, Linux, ...) certificate
// store.
using System;
using OpcLabs.EasyOpc.UA;
using OpcLabs.EasyOpc.UA.OperationModel;
namespace UADocExamples._UAApplicationParameters
{
class ApplicationCertificateStore
{
public static void PlatformSpecific()
{
UAEndpointDescriptor endpointDescriptor =
"opc.tcp://opcua.demo-this.com:51210/UA/SampleServer";
// or "http://opcua.demo-this.com:51211/UA/SampleServer" (not in .NET Standard)
// or "https://opcua.demo-this.com:51212/UA/SampleServer/"
// Set the application certificate store path, which determines the location of the client certificate.
// Note that this only works once in each host process.
EasyUAClient.SharedParameters.EngineParameters.ApplicationParameters.ApplicationCertificateStore = "CurrentUser\\My";
// Do something - invoke an OPC read, to trigger creation of the certificate.
var client = new EasyUAClient();
try
{
client.ReadValue(endpointDescriptor, "nsu=http://test.org/UA/Data/;i=10853");
}
catch (UAException uaException)
{
Console.WriteLine("*** Failure: {0}", uaException.GetBaseException().Message);
}
// The certificate will be located or created in the specified platform-specific certificate store.
// On Windows, when viewed by the certmgr.msc tool, it will be under
// Certificates - Current User -> Personal -> Certificates.
Console.WriteLine("Done.");
}
}
}
// This example demonstrates how to place the client certificate
// in the platform-specific (Windows, Linux, ...) certificate store.
class procedure ApplicationCertificateStore.PlatformSpecific;
var
Client: OpcLabs_EasyOpcUA_TLB._EasyUAClient;
ClientConfiguration: TEasyUAClientConfiguration;
Value: OleVariant;
begin
// The configuration object allows access to static behavior.
ClientConfiguration := TEasyUAClientConfiguration.Create(nil);
ClientConfiguration.Connect;
// Set the application certificate store path, which determines the location of the client certificate.
// Note that this only works once in each host process.
ClientConfiguration.SharedParameters.EngineParameters.ApplicationParameters.ApplicationCertificateStore :=
'CurrentUser\My';
// Do something - invoke an OPC read, to trigger creation of the certificate.
Client := CoEasyUAClient.Create;
try
Value := Client.ReadValue(
'http://opcua.demo-this.com:51211/UA/SampleServer',
'nsu=http://test.org/UA/Data/;i=10853');
except
on E: EOleException do
begin
WriteLn(Format('*** Failure: %s', [E.GetBaseException.Message]));
end;
end;
// The certificate will be located or created in the specified platform-specific certificate store.
// On Windows, when viewed by the certmgr.msc tool, it will be under
// Certificates - Current User -> Personal -> Certificates.
WriteLn('Done.');
FreeAndNil(ClientConfiguration);
end;
// This example demonstrates how to place the client certificate
// in the platform-specific (Windows, Linux, ...) certificate store.
// The configuration object allows access to static behavior.
$ClientConfiguration = new COM("OpcLabs.EasyOpc.UA.EasyUAClientConfiguration");
// Set the application certificate store path, which determines the location of the client certificate.
// Note that this only works once in each host process.
$ClientConfiguration->SharedParameters->EngineParameters->ApplicationParameters->ApplicationCertificateStore =
"CurrentUser\My";
// Do something - invoke an OPC read, to trigger creation of the certificate.
$Client = new COM("OpcLabs.EasyOpc.UA.EasyUAClient");
try
{
$value = $Client->ReadValue("http://opcua.demo-this.com:51211/UA/SampleServer", "nsu=http://test.org/UA/Data/;i=10853");
}
catch (com_exception $e)
{
printf("*** Failure: %s\n", $e->getMessage());
}
// The certificate will be located or created in the specified platform-specific certificate store.
// On Windows, when viewed by the certmgr.msc tool, it will be under
// Certificates - Current User -> Personal -> Certificates.
printf("Done.\n");
' This example demonstrates how to place the client certificate in the platform-specific (Windows, Linux, ...) certificate store.
Imports OpcLabs.EasyOpc.UA
Imports OpcLabs.EasyOpc.UA.OperationModel
Namespace UADocExamples._UAApplicationParameters
Friend Class ApplicationCertificateStore
Public Shared Sub PlatformSpecific()
' Define which server we will work with.
Dim endpointDescriptor As UAEndpointDescriptor =
"opc.tcp://opcua.demo-this.com:51210/UA/SampleServer"
' or "http://opcua.demo-this.com:51211/UA/SampleServer" (not in .NET Standard)
' or "https://opcua.demo-this.com:51212/UA/SampleServer/"
' Set the application certificate store path, which determines the location of the client certificate.
' Note that this only works once in each host process.
EasyUAClient.SharedParameters.EngineParameters.ApplicationParameters.ApplicationCertificateStore = "CurrentUser\\My"
' Do something - invoke an OPC read, to trigger creation of the certificate.
Dim client = New EasyUAClient()
Try
client.ReadValue(endpointDescriptor, "nsu=http://test.org/UA/Data/;i=10853")
Catch uaException As UAException
Console.WriteLine("*** Failure: {0}", uaException.GetBaseException.Message)
End Try
' The certificate will be located or created in the specified platform-specific certificate store.
' On Windows, when viewed by the certmgr.msc tool, it will be under
' Certificates - Current User -> Personal -> Certificates.
Console.WriteLine("Done.")
End Sub
End Class
End Namespace
Rem This example demonstrates how to place the client certificate in the platform-specific (Windows, Linux, ...) certificate
Rem store.
Rem Note: COM is only available on Windows.
Option Explicit
' The configuration object allows access to static behavior.
Dim ClientConfiguration: Set ClientConfiguration = CreateObject("OpcLabs.EasyOpc.UA.EasyUAClientConfiguration")
WScript.ConnectObject ClientConfiguration, "ClientConfiguration_"
' Set the application certificate store path, which determines the location of the client certificate.
' Note that this only works once in each host process.
ClientConfiguration.SharedParameters.EngineParameters.ApplicationParameters.ApplicationCertificateStore = "CurrentUser\My"
' Do something - invoke an OPC read, to trigger some loggable entries.
Dim Client: Set Client = CreateObject("OpcLabs.EasyOpc.UA.EasyUAClient")
On Error Resume Next
Dim value: value = Client.ReadValue("http://opcua.demo-this.com:51211/UA/SampleServer", "nsu=http://test.org/UA/Data/;i=10853")
If Err.Number <> 0 Then
WScript.Echo "*** Failure: " & Err.Source & ": " & Err.Description
WScript.Quit
End If
On Error Goto 0
' The certificate will be located or created in the specified platform-specific certificate store.
' On Windows, when viewed by the certmgr.msc tool, it will be under
' Certificates - Current User -> Personal -> Certificates.
WScript.Echo "Done."