OPC UA .Net Standard Stack and Samples
Overview
This OPC UA reference implementation is targeting the .NET Standard. .Net Standard allows developing apps that run on all common platforms available today, including Linux, iOS, Android (via Xamarin) and Windows 7/8/8.1/10 (including embedded/IoT editions) without requiring platform-specific modifications. Furthermore, cloud applications and services (such as ASP.Net, DNX, Azure Websites, Azure Webjobs, Azure Nano Server and Azure Service Fabric) are also supported. For more information and license terms, see here.
Features included
- Fully ported Core UA stack and SDK (Client, Server, Configuration & Sample assemblies)
- Sample Servers and Clients, including all required controls, for .Net 4.6.1, .NetCore 2.0 and UWP.
- X.509 certificate support for client and server authentication
- SHA512 support
- Anonymous, username and X.509 certificate user authentication
- UA-TCP & HTTPS transports (client and server)
- Folder & OS-level (X509Store) certificate-store support
- Sessions (including UI support in the samples)
- Subscriptions (including UI support in the samples)
- OPC UA Reference Server
- OPC UA Aggregation Server
- OPC Classic adapter for OPC UA
- OPC UA Global Discovery Client and Global Discovery Server
- OPC UA Certification Test Tool Version 1.03.340.358 compliant
Getting Started
All the tools you need for .Net Standard come with the .Net Core tools. See here for what you need.
Self signed certificates for the sample applications
All required application certificates for OPC UA are created at the first start of each application in a directory or OS-level certificate store and remain in use until deleted from the store.
Windows .Net applications
By default the self signed certificates are stored in a X509Store called CurrentUser\UA_MachineDefault. The certificates can be viewed or deleted with the Windows Certificate Management Console (certmgr.msc). The trusted, issuer and rejected stores remain in a folder called OPC Foundation\CertificateStores with a root folder which is specified by the environment variable ProgramData. On Windows 7/8/8.1/10 this is usually the invisible folder C:\ProgramData.
Note: Since the sample applications in the UA-.Net repository use the same storage and application names as UA-.NetStandard, but create only certificates with hostname localhost
, it is recommended to delete all existing certificates in MachineDefault to recreate proper certificates for all sample applications when moving to the UA-.NetStandard repository.
Windows UWP applications
By default the self signed certificates are stored in a X509Store called CurrentUser\UA_MachineDefault. The certificates can be viewed or deleted with the Windows Certificate Management Console (certmgr.msc). The trusted, issuer and rejected stores remain in a folder called OPC Foundation\CertificateStores in the LocalState folder of the installed universal windows package. Deleting the application state also deletes the certificate stores.
.Net Standard Console applications on Windows, Linux, iOS etc.
The self signed certificates are stored in OPC Foundation/CertificateStores/MachineDefault in each application project folder or in a X509Store called CurrentUser\My, depending on the configuration. For best cross platform support the personal store CurrentUser\My was chosen to support all platforms with the same configuration.
Local Discovery Server
By default all sample applications are configured to register with a Local Discovery Server (LDS). A reference implementation of a LDS for Windows can be downloaded from here. To setup trust with the LDS the certificates need to be exchanged or registration will fail.
How to build and run the samples in Visual Studio on Windows
- Open the UA-NetStandard.sln solution file using Visual Studio 2017.
- Choose a project in the Solution Explorer and set it with a right click as
Startup Project
. - Hit
F5
to build and execute the sample.
How to build and run the console samples on Windows, Linux and iOS
This section describes how to run the NetCoreConsoleClient and NetCoreConsoleServer sample applications.
Please follow instructions in this article to setup the dotnet command line environment for your platform. As of today .Net Standard 2.0 is required.
Prerequisites
- Once the
dotnet
command is available, navigate to the root folder in your local copy of the repository and executedotnet restore UA-NetStandard.sln
. This command calls into NuGet to restore the tree of dependencies.
Start the server
- Open a command prompt
- Now navigate to the folder SampleApplications/Samples/NetCoreConsoleServer.
- To run the server sample type
dotnet run
. The server is now running and waiting for connections.
Start the client
- Open a command prompt
- Now navigate to the folder SampleApplications/Samples/NetCoreConsoleClient.
- To execute the sample type
dotnet run
to connect to the OPC UA console sample server running on the same host. To connect to another OPC UA server specify the server as first argument and type e.g.dotnet run opc.tcp://myserver:51210/UA/SampleServer
. - On first connection, or after certificates were renewed, the server may have refused the client certificate. Check the server and client folder OPC Foundation\CertificateStores\RejectedCertificates for rejected certificates. To approve a certificate copy it to the OPC Foundation\CertificateStores\UA Applications folder.
- Retry step 3 to connect using a secure connection.
How to build and run the OPC UA COM Server Wrapper
- Please refer to the OPC Foundation UA .Net Standard Library COM Server Wrapper for a detailed description how to run the OPC COM wrapper.
How to build and run the OPC UA Aggregation Client and Server
- Please refer to the OPC Foundation UA .Net Standard Library Aggregation Client and Server for a detailed description how to run the aggregation client and server.
How to build and run the OPC UA Reference Server with UACTT
- Please refer to the OPC Foundation UA .Net Standard Library Reference Server for a detailed description how to run the reference server against the UACTT.
What happened to the OPC UA Web Telemetry sample?
The web telemetry sample was removed as there is a much more complete (and better looking!) solution now available here. You can try this new solution, called "Connected Factory", out here.
Contributing
We strongly encourage community participation and contribution to this project. First, please fork the repository and commit your changes there. Once happy with your changes you can generate a 'pull request'.
You must agree to the contributor license agreement before we can accept your changes. The CLA and "I AGREE" button is automatically displayed when you perform the pull request. You can preview CLA here.