Skip to content

Commit a1f9081

Browse files
Merge pull request #267890 from timlt/update-opcua
OPC UA updates from cristipogacean
2 parents 6fc3836 + f42ffd6 commit a1f9081

8 files changed

+663
-286
lines changed

articles/iot-operations/manage-devices-assets/howto-configure-opc-plc-simulator.md

Lines changed: 38 additions & 34 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,11 @@
11
---
22
title: Configure an OPC PLC simulator
3-
titleSuffix: Azure IoT OPC UA Broker
43
description: How to configure an OPC PLC simulator
54
author: timlt
65
ms.author: timlt
76
ms.subservice: opcua-broker
87
ms.topic: how-to
9-
ms.custom:
10-
- ignite-2023
11-
ms.date: 11/6/2023
8+
ms.date: 03/01/2024
129

1310
# CustomerIntent: As a developer, I want to configure an OPC PLC simulator in my
1411
# industrial edge environment to test the process of managing OPC UA assets connected to the simulator.
@@ -18,57 +15,64 @@ ms.date: 11/6/2023
1815

1916
[!INCLUDE [public-preview-note](../includes/public-preview-note.md)]
2017

21-
In this article, you learn how to implement an OPC UA server simulator with different nodes that generate random data, anomalies and configuration of user defined nodes. For developers, an OPC UA simulator enables you to test the process of managing OPC UA assets that are connected to the simulator.
18+
In this article, you learn how to configure and connect to an OPC UA server simulator with different nodes that generate random data, anomalies, and configuration of user defined nodes. For developers, an OPC UA simulator enables you to test the process of managing OPC UA assets that are connected to the simulator.
2219

2320
## Prerequisites
2421

25-
Azure IoT Operations Preview installed. For more information, see [Quickstart: Deploy Azure IoT Operations – to an Arc-enabled Kubernetes cluster](../get-started/quickstart-deploy.md). If you deploy Azure IoT Operations as described, the process installs an OPC PLC simulator.
22+
Azure IoT Operations installed. For more information, see [Quickstart: Deploy Azure IoT Operations – to an Arc-enabled Kubernetes cluster](../get-started/quickstart-deploy.md). If you deploy Azure IoT Operations as described, the process installs an OPC PLC simulator.
23+
24+
## Deploy the OPC PLC simulator
25+
26+
This section shows how to deploy the OPC PLC simulator.
27+
28+
> [!IMPORTANT]
29+
> Don't use the following example in production, use it for simulation and test purposes only. The example lowers the security level for the OPC PLC so that it accepts connections from any client without an explicit peer certificate trust operation.
30+
31+
Run the following code to update the OPC UA Broker deployment and apply the new settings:
32+
33+
```bash
34+
az k8s-extension update \
35+
--version 0.3.0-preview \
36+
--name opc-ua-broker \
37+
--release-train preview \
38+
--cluster-name <cluster-name> \
39+
--resource-group <azure-resource-group> \
40+
--cluster-type connectedClusters \
41+
--auto-upgrade-minor-version false \
42+
--config opcPlcSimulation.deploy=true \
43+
--config opcPlcSimulation.autoAcceptUntrustedCertificates=true
44+
```
45+
46+
The OPC PLC OPC UA server should run in the same deployment as a separate pod.
2647

2748
## Get the certificate of the OPC PLC simulator
28-
If you deploy Azure IoT Operations with the OPC PLC simulator enabled, you can get the certificate of the PLC named `simulationPlc`. By getting the certificate, you can run the simulator with mutual trust.
49+
The application instance certificate of the OPC PLC is a self-signed certificate managed by cert-manager and stored in the `secret aio-opc-ua-opcplc-default-application-cert-000000` kubernetes secret.
2950

3051
To get the certificate, run the following commands on your cluster:
3152

3253
```bash
33-
# Copy the public cert of the simulationPlc in the cluster to a local folder
54+
# extract the public key of the opc plc from the kubernetes secret
55+
kubectl -n azure-iot-operations get secret aio-opc-ua-opcplc-default-application-cert-000000 -o jsonpath='{.data.tls\.crt}' | base64 -d > opcplc.crt
3456

35-
OPC_PLC_POD=$(kubectl get pod -l app.kubernetes.io/name=opcplc -n azure-iot-operations -o jsonpath="{.items[0].metadata.name}")
36-
SERVER_CERT=$(kubectl exec $OPC_PLC_POD -n azure-iot-operations -- ls /app/pki/own/certs)
37-
kubectl cp azure-iot-operations/${OPC_PLC_POD}:/app/pki/own/certs/${SERVER_CERT} my-server.der
57+
# optionally transform the certificate in *.der format
58+
openssl x509 -outform der -in opcplc.crt -out opcplc.der
3859
```
3960

40-
## Configure OPC UA transport authentication
41-
After you get the simulator's certificate, the next step is to configure authentication.
42-
43-
1. To complete this configuration, follow the steps in [Configure OPC UA transport authentication](howto-configure-opcua-authentication-options.md#configure-opc-ua-transport-authentication).
44-
45-
1. Optionally, rather than configure a secret provider class CR, you can configure a self-signed certificate for transport authentication.
46-
47-
To create a self-signed certificate to test transport authentication, run the following command:
48-
49-
```bash
50-
# Create cert.pem and key.pem
51-
openssl req -x509 -newkey rsa:2048 -keyout key.pem -out cert.pem -sha256 -days 365 -nodes \
52-
-subj "/CN=opcuabroker/O=Microsoft" \
53-
-addext "subjectAltName=URI:urn:microsoft.com:opc:ua:broker" \
54-
-addext "keyUsage=critical, nonRepudiation, digitalSignature, keyEncipherment, dataEncipherment, keyCertSign" \
55-
-addext "extendedKeyUsage = critical, serverAuth, clientAuth" \
56-
-addext "basicConstraints=CA:FALSE"
57-
```
58-
5961
## Configure OPC UA mutual trust
60-
Another OPC UA authentication option you can configure is mutual trust. In OPC UA communication, the OPC UA client and server both confirm the identity of each other.
62+
The next step in OPC UA authentication is to configure mutual trust. In OPC UA communication, the OPC UA client and server authenticate each other.
63+
64+
To complete this configuration, follow the steps to [configure mutual trust](howto-configure-opcua-certificates-infrastructure.md#how-to-handle-the-opc-ua-trusted-certificates-list). Use the certificate file you extracted in the previous section.
6165

62-
To complete this configuration, follow the steps in [Configure OPC UA mutual trust](howto-configure-opcua-authentication-options.md#configure-opc-ua-mutual-trust).
66+
For simplicity, on the OPC PLC you don't need to do a mutual trust action. Mutual trust is configured with `autoAcceptUntrustedCertificates`, which accepts connections from any OPC UA client.
6367

6468
## Optionally configure for no authentication
6569

66-
You can optionally configure an OPC PLC to run with no authentication. If you understand the risks, you can turn off authentication for testing purposes.
70+
You can optionally configure an asset endpoint profile for the OPC PLC to run without mutual trust established. If you understand the risks, you can turn off authentication for testing purposes.
6771

6872
> [!CAUTION]
6973
> Don't configure for no authentication in production or pre-production. Exposing your cluster to the internet without authentication can lead to unauthorized access and even DDOS attacks.
7074
71-
To run an OPC PLC with no security profile, you can manually adjust the `AssetEndpointProfile` for OPC UA with the `additionalConfiguration` setting.
75+
To allow your asset endpoint profile to connect to any OPC PLC server without establishing mutual trust, use the `additionalConfiguration` setting to change the `AssetEndpointProfile` for OPC UA.
7276

7377
Configure the setting as shown in the following example JSON code:
7478

0 commit comments

Comments
 (0)