![Avatar](https://newwebsite.opcfoundation.org/wp-content/uploads/sp-resources/forum-avatars/defaults/userdefault.png)
04/05/2023
![sp_UserOfflineSmall](https://newwebsite.opcfoundation.org/wp-content/sp-resources/forum-themes/reboot/images/darkpack/sp_UserOfflineSmall.png)
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)