The default behavior of QuickOPC is to automatically generate a "subject name" for the instance certificate of the UA client application. QuickOPC then attempts to locate the certificate using this subject name in the certificate store, and if it finds such certificate, it uses it. If it does not find such certificate, it creates it and places it into the certificate store (so that it can be found next time, and not re-created).
If you want to provide your own certificate to be used by QuickOPC as UA client certificate, you either need to generate it with the subject name that QuickOPC uses (beware: it may change depending on conditions such as your assembly version and name!), or choose your own name, and instruct QuickOPC to use that name.
Here is an information on how to achieve it:
In general, you just need to set the ApplicationName property in EasyUAClient.SharedParameters.EngineParameters to the desired certificate subject. This can be directly in .NET, but because static properties are not supported in COM, it has to be done via the EasyUAClientConfiguration object in tools such as VBScript, VB6, VBA (Excel, ...), Delphi etc.
Code examples follow, and are also in attachments.
C#:
// Note that this only works once in each application domain.
EasyUAClient.SharedParameters.EngineParameters.ApplicationName = "My Application";
EasyUAClient.SharedParameters.EngineParameters.ApplicationUriString = "http://opcua.demo-this.com/MyApplication"; // optional
// Do something - invoke an OPC read.
new EasyUAClient().ReadValue("http://opcua.demo-this.com:51211/UA/SampleServer", "nsu=http://test.org/UA/Data/;i=10853");
// The certificate will be located or created in a directory similar to:
// C:\Users\All Users\OPC Foundation\CertificateStores\UA Applications\certs\
// and its subject will be as given by the application name.
VBScript:
Rem This example demonstrates how to set the application name for the client certificate.
Option Explicit
' The configuration object allows access to static behavior.
Dim ClientConfiguration: Set ClientConfiguration = CreateObject("OpcLabs.EasyOpc.UA.EasyUAClientConfiguration")
' Set the application name, which determins the subject of the client certificate.
' Note that this only works once in each host process.
ClientConfiguration.SharedParameters.EngineParameters.ApplicationName = "QuickOPC - VBScript example application"
' Do something - invoke an OPC read.
Dim Client: Set Client = CreateObject("OpcLabs.EasyOpc.UA.EasyUAClient")
Dim value: value = Client.ReadValue("http://opcua.demo-this.com:51211/UA/SampleServer", "nsu=http://test.org/UA/Data/;i=10853")
' The certificate will be located or created in a directory similar to:
' C:\Users\All Users\OPC Foundation\CertificateStores\UA Applications\certs\
' and its subject will be as given by the application name.
VBA (in Excel):
Private Sub Workbook_Open()
' Sets the application name for the client certificate.
' The configuration object allows access to static behavior.
Dim ClientConfiguration As New EasyUAClientConfiguration
' Set the application name, which determins the subject of the client certificate.
' Note that this only works once in each host process.
ClientConfiguration.SharedParameters.EngineParameters.ApplicationName = "QuickOPC - VBA example application"
' Create EasyOPC-UA component
Dim Client As New EasyUAClient
' Do something - invoke an OPC read.
Range("A1").Value = Client.ReadValue("http://opcua.demo-this.com:51211/UA/SampleServer", "nsu=http://test.org/UA/Data/;i=10853")
' The certificate will be located or created in a directory similar to:
' C:\Users\All Users\OPC Foundation\CertificateStores\UA Applications\certs\
' and its subject will be as given by the application name.
End Sub
Note: Some earlier QuickOPC versions had a bug which caused the changes to shared parameters be ignored. If you observe such problem, download QuickOPC 5.40.281.1 or later, and rebuild your project with the new assemblies.