04/05/2023
Hi,
I’m trying for the first time to connect to a PLC using OPC UA protocol but I receive this error: Opc.Ua.ServiceResultException: ‘ApplicationCertificate cannot be found.’
Opc.Ua.ServiceResultException: ‘ApplicationCertificate cannot be found.’ below the code, making debug certificate seem to be in the right position
Â
var endpointUrl = “opc.tcp://192.168.1.162:48010”; // URL del server OPC UA
var endpoint = new EndpointDescription
{
EndpointUrl = endpointUrl
};
var applicationConfiguration = new ApplicationConfiguration
{
ApplicationName = “OPC UA Client”,
ApplicationType = ApplicationType.Client,
SecurityConfiguration = new SecurityConfiguration
{
ApplicationCertificate = new CertificateIdentifier
{
StoreType = @”Directory”,
StorePath = System.Windows.Forms.Application.StartupPath + @”\Cert\TrustedIssuer\private”,
SubjectName = “CN=testopcua, DC=” + System.Net.Dns.GetHostName()
},
TrustedPeerCertificates = new CertificateTrustList(),
TrustedIssuerCertificates = new CertificateTrustList(),
RejectedCertificateStore = new CertificateStoreIdentifier(),
AutoAcceptUntrustedCertificates = true
}
};
var endpointConfiguration = EndpointConfiguration.Create(applicationConfiguration);
var endpointDescription = new ConfiguredEndpoint(null, endpoint, endpointConfiguration);
var session = Session.Create(
applicationConfiguration,
endpointDescription,
false,
“”,
60000,
null,
null
).GetAwaiter().GetResult();
1 Guest(s)