OPC ua connect: ApplicationCertificate cannot be found.|OPC UA Standard|Forum|OPC Foundation

Avatar
Search
Forum Scope


Match



Forum Options



Minimum search word length is 3 characters - maximum search word length is 84 characters
Lost password?
sp_Feed sp_PrintTopic sp_TopicIcon
OPC ua connect: ApplicationCertificate cannot be found.
Avatar
Tonini Massimo
Member
Members
Forum Posts: 3
Member Since:
04/05/2023
sp_UserOfflineSmall Offline
1
06/26/2023 - 02:16
sp_Permalink sp_Print

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();

Avatar
Randy Armstrong
Admin
Forum Posts: 1455
Member Since:
05/30/2017
sp_UserOfflineSmall Offline
2
06/26/2023 - 16:32
sp_Permalink sp_Print

StorePath should point to 1 directory up.

Avatar
Tonini Massimo
Member
Members
Forum Posts: 3
Member Since:
04/05/2023
sp_UserOfflineSmall Offline
3
06/27/2023 - 01:35
sp_Permalink sp_Print

You are right (I changed because it gived me the same error):

StorePath = System.Windows.Forms.Application.StartupPath + @"\Cert\TrustedIssuer",

Avatar
Randy Armstrong
Admin
Forum Posts: 1455
Member Since:
05/30/2017
sp_UserOfflineSmall Offline
4
06/29/2023 - 15:07
sp_Permalink sp_Print

This can occur due to mismatch between the subject name in configuration and the cert on disk.

Forum Timezone: America/Phoenix
Most Users Ever Online: 510
Currently Online: Liu Hongxin
Guest(s) 17
Currently Browsing this Page:
1 Guest(s)
Top Posters:
Forum Stats:
Groups: 2
Forums: 10
Topics: 1353
Posts: 4586