Quantcast
Channel: OPC Labs - OPC Labs - Recent Topics - OPC Labs Online Forums
Viewing all articles
Browse latest Browse all 1794

CryptographicException when connecting to Opc UA server - by: Cavallari

$
0
0
CryptographicException when connecting to Opc UA server
Dear support service,
we’re experiencing problems in connecting to an Opc UA server through OpcLabs.QuickOpc 5.60.107.
As soon as our application tries to perform an operation (browse/read) on the Opc server, a CryptographicException with the following message is thrown:



Searching on the forum, I found that the problem could be related to client-side certificates:

https://www.opclabs.com/forum/ua-com-product-lifecycle-licensing/2604-how-do-we-access-the-easyuaclient

so I followed the instructions described in the post, but without success.
The strange thing is that the exception is thrown regardless of the endpoint that is specified for the connection (I tried both an existing and an invalid server), so I suspect that the exception is thrown before the connection attempt.
Starting from a “clean” situation (no certificate for the client application is present in the “C:\ProgramData\OPC Foundation\CertificateStores\” folder or in any of its subfolder), when I start the application, a certificate (that, considering its name, is related to the client application) is created in the “MachineDefault\certs”, “MachineDefault\private” and “UA Applications\certs” folders, but the exception is thrown. The file has the same name in all the three folders.

Starting again from a “clean” situation, but running the client application with administrative rights, the certificates are re-generated, and the application succeeds in connecting and reading from the Opc Sever, but, after this, if I start again the application without administrative rights, the exception is still throw.

Our test environment is the following:
  • Virtual machine with Windows 10 x64 Build 1909. No domain configured (machine is in the default workgroup), the local user running the application is a local administrator, but usually the application is executed without elevated privileges.
  • Microsoft Visual Studio 2019
  • C# Console application (Framework 4.7.2) using OpcLabs.QuickOpc 5.60.107 NuGet package, in demo version. I also tried 5.56.1073 fully licensed: the result is the same (exception is thrown), but no certificate is created in the CertificateStores folder. If this second application is run with elevated privileges, an exception with the message “OPC-UA service result - Self Signed Certificate is not trusted” is thrown.

Here follows the sample code that generates the exception:



Please let us know if you need additional information.

Thanks in advance for support,
Jacopo

Viewing all articles
Browse latest Browse all 1794

Trending Articles