4

When I run OPC-UA server C# application in windows machine then OPC-UA server has created a certificate path C:\ProgramData\OPC Foundation\pki\own and generates some certificates inside this path, but when I installed OPC-UA server in Linux machine then certificate path has not been created by server application and I am not getting any kind of error like access to the path denied. I am using below lines for creating certificate path in configuration file. Please help us.

<ApplicationCertificate>
            <StoreType>Directory</StoreType>
            <StorePath>%CommonApplicationData%\OPC Foundation\pki\own</StorePath>
            <SubjectName>CN=OPCUA Server, C=US, S=Arizona, O=OPC Foundation, DC=localhost</SubjectName>
</ApplicationCertificate>
Md Shahnewaz
  • 121
  • 4

1 Answers1

0

First of all on linux it is recommended to use: %LocalApplicationData%

ENM: System.Environment.SpecialFolder.LocalApplicationData
WIN: C:\Users\USER\AppData\Local
LIN: /home/USER/.local/share
OSX: /Users/USER/.local/share

If you run it as superuser /root/.local/share is the path.

If you run it as normal user /home/victor/.local/share

If you want to see the path of a special folder use this:

Console.WriteLine("My folder: " + Environment.GetFolderPath( Environment.SpecialFolder.LocalApplicationData));

Superuser path: my folder

Normaluser path: normal user

This might help you locate your folders.

Since I ran the program as superuser it is in the (USER)->root/.local/share You can only access this folder when logged in as root

location

Here is anotherone with normal user:

normal user

My Securityconfiguration (I made a client but I guess it is almost the same with server):

    SecurityConfiguration = new SecurityConfiguration
                {
                    ApplicationCertificate = new CertificateIdentifier { StoreType = @"Directory", StorePath = @"%LocalApplicationData%/OPCFoundation/CertificateStores/MachineDefault", SubjectName = "Mything" },
                    TrustedIssuerCertificates = new CertificateTrustList { StoreType = @"Directory", StorePath = @"%LocalApplicationData%/OPCFoundation/CertificateStores/UA Certificate Authorities" },
                    TrustedPeerCertificates = new CertificateTrustList { StoreType = @"Directory", StorePath = @"%LocalApplicationData%/OPCFoundation/CertificateStores/UA Applications" },
                    RejectedCertificateStore = new CertificateTrustList { StoreType = @"Directory", StorePath = @"%LocalApplicationData%/OPCFoundation/CertificateStores/RejectedCertificates" },
                    AutoAcceptUntrustedCertificates = true,
                    AddAppCertToTrustedStore = true
                },

This code will create the certificate on runtime:

application.CheckApplicationInstanceCertificate(false, 2048).GetAwaiter().GetResult();
Victor Pieper
  • 540
  • 2
  • 17