OPCFoundation / UA-.NETStandard

OPC Unified Architecture .NET Standard
Other
1.95k stars 945 forks source link

DirectoryCertificateStore.Load throws exception on Linux #112

Closed mregen closed 7 years ago

mregen commented 7 years ago

Different behaviour on Windows and Linux: FileSystemInfo.LastWriteTimeUtc throws exception if the folder doesn't exist.

Workaround create an empty folder UA Applications/private beside certs, otherwise own cert cannot be copied to trusted store, which may cause some strange certificate validation errors.

06:41:08.828 Checking application instance certificate. 06:41:08.832 Checking application instance certificate. CN=Opc.Ua.TestStation, DC=mregen-ubuntu16 06:41:09.057 Checking domains in certificate. CN=Opc.Ua.TestStation, DC=mregen-ubuntu16 06:41:09.068 Adding certificate to trusted peer store. StorePath=../OPC Foundation/CertificateStores/UA Applications 06:41:09.108 Could not add certificate to trusted peer store. StorePath=../OPC Foundation/CertificateStores/UA Applications FileNotFoundException 'Could not find file '/home/martin/azure-iot-stuttgart/Simulation/Factory/OPC Foundation/CertificateStores/UA Applications/private'.'

======================================== Id: Bad Description: Could not find file '/home/martin/azure-iot-stuttgart/Simulation/Factory/OPC Foundation/CertificateStores/UA Applications/private'. Could not find file '/home/martin/azure-iot-stuttgart/Simulation/Factory/OPC Foundation/CertificateStores/UA Applications/private'. --- at System.IO.FileSystemInfo.EnsureStatInitialized() --- at System.IO.FileSystemInfo.System.IO.IFileSystemObject.get_LastWriteTime() --- at System.IO.FileSystemInfo.get_LastWriteTimeUtc() --- at Opc.Ua.DirectoryCertificateStore.Load(String thumbprint) in /home/martin/UA-.NetStandardLibrary/Stack/Opc.Ua.Core/Security/Certificates/DirectoryCertificateStore.cs:line 726 --- at Opc.Ua.DirectoryCertificateStore.Enumerate() in /home/martin/UA-.NetStandardLibrary/Stack/Opc.Ua.Core/Security/Certificates/DirectoryCertificateStore.cs:line 109 --- at Opc.Ua.Configuration.ApplicationInstance.d__58.MoveNext() in /home/martin/UA-.NetStandardLibrary/SampleApplications/SDK/Opc.Ua.Configuration/ApplicationInstance.cs:line 1486

========================================

https://github.com/dotnet/corefx/issues/15027

mregen commented 7 years ago

Turns out we need to fix this in the opc.ua.core codebase

for detailed info: https://github.com/dotnet/corefx/issues/1728