Skip to content

Commit 4303383

Browse files
authored
Merge pull request #86034 from v-stadam/x509_deploy_dps_0816
Use X.509 with DPS enrollments
2 parents f7f58c1 + d389b19 commit 4303383

5 files changed

+137
-116
lines changed

articles/iot-edge/TOC.yml

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -135,14 +135,14 @@
135135
href: how-to-update-iot-edge.md
136136
- name: Auto-provision with DPS
137137
items:
138-
- name: Symmetric key attestation
139-
href: how-to-auto-provision-symmetric-keys.md
140138
- name: TPM attestation
141139
items:
142140
- name: Linux
143141
href: how-to-auto-provision-simulated-device-linux.md
144142
- name: Windows
145-
href: how-to-auto-provision-simulated-device-windows.md
143+
href: how-to-auto-provision-simulated-device-windows.md
144+
- name: Symmetric key attestation
145+
href: how-to-auto-provision-symmetric-keys.md
146146
- name: Develop and debug custom modules
147147
items:
148148
- name: Visual Studio 2019

articles/iot-edge/how-to-auto-provision-simulated-device-linux.md

Lines changed: 57 additions & 48 deletions
Original file line numberDiff line numberDiff line change
@@ -13,21 +13,28 @@ ms.custom: seodec18
1313

1414
# Create and provision an IoT Edge device with a virtual TPM on a Linux virtual machine
1515

16-
Azure IoT Edge devices can be automatically provisioned using the [Device Provisioning Service](../iot-dps/index.yml). If you're unfamiliar with the process of autoprovisioning, review the [autoprovisioning concepts](../iot-dps/concepts-auto-provisioning.md) before continuing.
16+
Azure IoT Edge devices can be automatically provisioned using the [Device Provisioning Service](../iot-dps/index.yml). If you're unfamiliar with the process of auto-provisioning, review the [auto-provisioning concepts](../iot-dps/concepts-auto-provisioning.md) before continuing.
1717

18-
This article shows you how to test autoprovisioning on a simulated IoT Edge device with the following steps:
18+
This article shows you how to test auto-provisioning on a simulated IoT Edge device with the following steps:
1919

2020
* Create a Linux virtual machine (VM) in Hyper-V with a simulated Trusted Platform Module (TPM) for hardware security.
2121
* Create an instance of IoT Hub Device Provisioning Service (DPS).
2222
* Create an individual enrollment for the device
2323
* Install the IoT Edge runtime and connect the device to IoT Hub
2424

25-
The steps in this article are meant for testing purposes.
25+
> [!NOTE]
26+
> TPM 2.0 is required when using TPM attestation with DPS and can only be used to create individual, not group, enrollments.
27+
28+
> [!TIP]
29+
> This article describes how to test DPS provisioning using a TPM simulator, but much of it applies to physical TPM hardware such as the [Infineon OPTIGA™ TPM](https://catalog.azureiotsolutions.com/details?title=OPTIGA-TPM-SLB-9670-Iridium-Board), an Azure Certified for IoT device.
30+
>
31+
> If you're using a physical device, you can skip ahead to the [Retrieve provisioning information from a physical device](#retrieve-provisioning-information-from-a-physical-device) section in this article.
2632
2733
## Prerequisites
2834

29-
* A Windows development machine with [Hyper-V enabled](https://docs.microsoft.com/virtualization/hyper-v-on-windows/quick-start/enable-hyper-v). This article uses Windows 10 running an Ubuntu Server VM.
30-
* An active IoT Hub.
35+
* A Windows development machine with [Hyper-V enabled](https://docs.microsoft.com/virtualization/hyper-v-on-windows/quick-start/enable-hyper-v). This article uses Windows 10 running an Ubuntu Server VM.
36+
* An active IoT Hub.
37+
* If using a simulated TPM, [Visual Studio](https://visualstudio.microsoft.com/vs/) 2015 or later with the ['Desktop development with C++'](https://www.visualstudio.com/vs/support/selecting-workloads-visual-studio-2017/) workload enabled.
3138

3239
## Create a Linux virtual machine with a virtual TPM
3340

@@ -67,7 +74,7 @@ It may take a few minutes to create the new VM.
6774

6875
### Enable virtual TPM
6976

70-
Once your VM is created, open its settings to enable the virtual trusted platform module (TPM) that lets you autoprovision the device.
77+
Once your VM is created, open its settings to enable the virtual trusted platform module (TPM) that lets you auto-provision the device.
7178

7279
1. Select the virtual machine, then open its **Settings**.
7380

@@ -81,18 +88,48 @@ Once your VM is created, open its settings to enable the virtual trusted platfor
8188

8289
### Start the virtual machine and collect TPM data
8390

84-
In the virtual machine, build a C SDK tool that you can use to retrieve the device's **Registration ID** and **Endorsement Key**.
91+
In the virtual machine, build a tool that you can use to retrieve the device's **Registration ID** and **Endorsement key**.
8592

8693
1. Start your virtual machine and connect to it.
8794

88-
2. Follow the prompts within the virtual machine to finish the installation process and reboot the machine.
95+
1. Follow the prompts within the virtual machine to finish the installation process and reboot the machine.
8996

90-
3. Sign in to your VM, then follow the steps in [Set up a Linux development environment](https://github.com/Azure/azure-iot-sdk-c/blob/master/doc/devbox_setup.md#linux) to install and build the Azure IoT device SDK for C.
97+
1. Sign in to your VM, then follow the steps in [Set up a Linux development environment](https://github.com/Azure/azure-iot-sdk-c/blob/master/doc/devbox_setup.md#linux) to install and build the Azure IoT device SDK for C.
9198

9299
>[!TIP]
93-
>In the course of this article, you'll copy to and paste from the virtual machine, which is not easy through the Hyper-V Manager connection application. You may want to connect to virtual machine through Hyper-V Manager once to retrieve its IP address: `ifconfig`. Then, you can use the IP address to connect through SSH: `ssh <username>@<ipaddress>`.
100+
>In the course of this article, you'll copy to and paste from the virtual machine, which is not easy through the Hyper-V Manager connection application. You may want to connect to the virtual machine through Hyper-V Manager once to retrieve its IP address: `ifconfig`. Then, you can use the IP address to connect through SSH: `ssh <username>@<ipaddress>`.
94101
95-
4. Run the following commands to build an C SDK tool that retrieves your device provisioning information.
102+
1. Run the following commands to build the SDK tool that retrieves your device provisioning information from the TPM simulator.
103+
104+
```bash
105+
cd azure-iot-sdk-c/cmake
106+
cmake -Duse_prov_client:BOOL=ON -Duse_tpm_simulator:BOOL=ON ..
107+
cd provisioning_client/tools/tpm_device_provision
108+
make
109+
sudo ./tpm_device_provision
110+
```
111+
112+
1. From a command window, navigate to the `azure-iot-sdk-c` directory and run the TPM simulator. It listens over a socket on ports 2321 and 2322. Do not close this command window; you will need to keep this simulator running.
113+
114+
From the `azure-iot-sdk-c` directory, run the following command to start the simulator:
115+
116+
```bash
117+
./provisioning_client/deps/utpm/tools/tpm_simulator/Simulator.exe
118+
```
119+
120+
1. Using Visual Studio, open the solution generated in the `cmake` directory named `azure_iot_sdks.sln`, and build it using the **Build solution** command on the **Build** menu.
121+
122+
1. In the **Solution Explorer** pane in Visual Studio, navigate to the folder **Provision\_Tools**. Right-click the **tpm_device_provision** project and select **Set as Startup Project**.
123+
124+
1. Run the solution using either of the **Start** commands on the **Debug** menu. The output window displays the TPM simulator's **Registration ID** and the **Endorsement key**, which you should copy for use later when you create an individual enrollment for your device in You can close this window (with Registration ID and Endorsement key), but leave the TPM simulator window running.
125+
126+
## Retrieve provisioning information from a physical device
127+
128+
On your device, build a tool that you can use to retrieve the device's provisioning information.
129+
130+
1. Follow the steps in [Set up a Linux development environment](https://github.com/Azure/azure-iot-sdk-c/blob/master/doc/devbox_setup.md#linux) to install and build the Azure IoT device SDK for C.
131+
132+
1. Run the following commands to build the SDK tool that retrieves your device provisioning information from the TPM device.
96133

97134
```bash
98135
cd azure-iot-sdk-c/cmake
@@ -101,10 +138,8 @@ In the virtual machine, build a C SDK tool that you can use to retrieve the devi
101138
make
102139
sudo ./tpm_device_provision
103140
```
104-
>[!TIP]
105-
>If you are testing with TPM simulator, you'll need to put an extra parameter `-Duse_tpm_simulator:BOOL=ON` to enable it. The full command will be `cmake -Duse_prov_client:BOOL=ON -Duse_tpm_simulator:BOOL=ON ..`.
106141

107-
5. Copy the values for **Registration ID** and **Endorsement Key**. You use these values to create an individual enrollment for your device in DPS.
142+
1. Copy the values for **Registration ID** and **Endorsement key**. You use these values to create an individual enrollment for your device in DPS.
108143

109144
## Set up the IoT Hub Device Provisioning Service
110145

@@ -125,15 +160,18 @@ When you create an enrollment in DPS, you have the opportunity to declare an **I
125160
3. Select **Add individual enrollment** then complete the following steps to configure the enrollment:
126161

127162
1. For **Mechanism**, select **TPM**.
128-
163+
129164
2. Provide the **Endorsement key** and **Registration ID** that you copied from your virtual machine.
130-
165+
166+
> [!TIP]
167+
> If you're using a physical TPM device, you need to determine the **Endorsement key**, which is unique to each TPM chip and is obtained from the TPM chip manufacturer associated with it. You can derive a unique **Registration ID** for your TPM device by, for example, creating an SHA-256 hash of the endorsement key.
168+
131169
3. Select **True** to declare that this virtual machine is an IoT Edge device.
132-
170+
133171
4. Choose the linked **IoT Hub** that you want to connect your device to. You can choose multiple hubs, and the device will be assigned to one of them according to the selected allocation policy.
134-
172+
135173
5. Provide an ID for your device if you'd like. You can use device IDs to target an individual device for module deployment. If you don't provide a device ID, the registration ID is used.
136-
174+
137175
6. Add a tag value to the **Initial Device Twin State** if you'd like. You can use tags to target groups of devices for module deployment. For example:
138176

139177
```json
@@ -212,35 +250,6 @@ You can give TPM access to the IoT Edge runtime by overriding the systemd settin
212250

213251
If you don't see that the correct permissions have been applied, try rebooting your machine to refresh udev.
214252

215-
8. Open the IoT Edge runtime overrides file.
216-
217-
```bash
218-
sudo systemctl edit iotedge.service
219-
```
220-
221-
9. Add the following code to establish a TPM environment variable.
222-
223-
```input
224-
[Service]
225-
Environment=IOTEDGE_USE_TPM_DEVICE=ON
226-
```
227-
228-
10. Save and exit the file.
229-
230-
11. Verify that the override was successful.
231-
232-
```bash
233-
sudo systemctl cat iotedge.service
234-
```
235-
236-
Successful output displays the **iotedge** default service variables, and then shows the environment variable that you set in **override.conf**.
237-
238-
12. Reload the settings.
239-
240-
```bash
241-
sudo systemctl daemon-reload
242-
```
243-
244253
## Restart the IoT Edge runtime
245254

246255
Restart the IoT Edge runtime so that it picks up all the configuration changes that you made on the device.

articles/iot-edge/how-to-auto-provision-simulated-device-windows.md

Lines changed: 44 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
---
2-
title: Auto-provision Windows devices with DPS - Azure IoT Edge | Microsoft Docs
2+
title: Automatically provision Windows devices with DPS - Azure IoT Edge | Microsoft Docs
33
description: Use a simulated device on your Windows machine to test automatic device provisioning for Azure IoT Edge with Device Provisioning Service
44
author: kgremban
55
manager: philmea
@@ -11,17 +11,23 @@ services: iot-edge
1111
ms.custom: seodec18
1212
---
1313

14-
# Create and provision a simulated TPM Edge device on Windows
14+
# Create and provision a simulated IoT Edge device with a virtual TPM on Windows
1515

1616
Azure IoT Edge devices can be auto-provisioned using the [Device Provisioning Service](../iot-dps/index.yml) just like devices that are not edge-enabled. If you're unfamiliar with the process of auto-provisioning, review the [auto-provisioning concepts](../iot-dps/concepts-auto-provisioning.md) before continuing.
1717

18-
This article shows you how to test auto-provisioning on a simulated Edge device with the following steps:
18+
This article shows you how to test auto-provisioning on a simulated IoT Edge device with the following steps:
1919

2020
* Create an instance of IoT Hub Device Provisioning Service (DPS).
2121
* Create a simulated device on your Windows machine with a simulated Trusted Platform Module (TPM) for hardware security.
2222
* Create an individual enrollment for the device.
2323
* Install the IoT Edge runtime and connect the device to IoT Hub.
2424

25+
> [!NOTE]
26+
> TPM 2.0 is required when using TPM attestation with DPS and can only be used to create individual, not group, enrollments.
27+
28+
> [!TIP]
29+
> This article describes testing auto-provisioning by using TPM attestation on virtual devices, but much of it applies when using physical TPM hardware as well.
30+
2531
## Prerequisites
2632

2733
* A Windows development machine. This article uses Windows 10.
@@ -33,9 +39,14 @@ Create a new instance of the IoT Hub Device Provisioning Service in Azure, and l
3339

3440
After you have the Device Provisioning Service running, copy the value of **ID Scope** from the overview page. You use this value when you configure the IoT Edge runtime.
3541

42+
> [!TIP]
43+
> If you're using a physical TPM device, you need to determine the **Endorsement key**, which is unique to each TPM chip and is obtained from the TPM chip manufacturer associated with it. You can derive a unique **Registration ID** for your TPM device by, for example, creating an SHA-256 hash of the endorsement key.
44+
>
45+
> Follow the instructions in the article [How to manage device enrollments with Azure Portal](../iot-dps/how-to-manage-enrollments.md) to create your enrollment in DPS and then proceed with the [Install the IoT Edge runtime](#install-the-iot-edge-runtime) section in this article to continue.
46+
3647
## Simulate a TPM device
3748

38-
Create a simulated TPM device on your Windows development machine. Retrieve the **Registration ID** and **Endorsement Key** for your device, and use them to create an individual enrollment entry in DPS.
49+
Create a simulated TPM device on your Windows development machine. Retrieve the **Registration ID** and **Endorsement key** for your device, and use them to create an individual enrollment entry in DPS.
3950

4051
When you create an enrollment in DPS, you have the opportunity to declare an **Initial Device Twin State**. In the device twin you can set tags to group devices by any metric you need in your solution, like region, environment, location, or device type. These tags are used to create [automatic deployments](how-to-deploy-monitor.md).
4152

@@ -55,15 +66,39 @@ After creating the individual enrollment, save the value of the **Registration I
5566

5667
## Install the IoT Edge runtime
5768

58-
After completing the previous section, you should see your new device listed as an IoT Edge device in your IoT Hub. Now, you need to install the IoT Edge runtime on your device.
69+
The IoT Edge runtime is deployed on all IoT Edge devices. Its components run in containers, and allow you to deploy additional containers to the device so that you can run code at the edge.
70+
71+
You'll need the following information when provisioning your device:
72+
73+
* The DPS **ID Scope** value
74+
* The device **Registration ID** you created
75+
76+
Install the IoT Edge runtime on the device that is running the simulated TPM. You'll configure the IoT Edge runtime for automatic, not manual, provisioning.
5977

60-
The IoT Edge runtime is deployed on all IoT Edge devices. Its components run in containers, and allow you to deploy additional containers to the device so that you can run code at the edge.
78+
> [!TIP]
79+
> Keep the window that's running the TPM simulator open during your installation and testing.
6180
62-
Follow the instructions to install the IoT Edge runtime on the device that is running the simulated TPM from the previous section. Make sure to configure the IoT Edge runtime for automatic, not manual, provisioning.
81+
For more detailed information about installing IoT Edge on Windows, including prerequisites and instructions for tasks like managing containers and updating IoT Edge, see [Install the Azure IoT Edge runtime on Windows](how-to-install-iot-edge-windows.md).
6382

64-
Know your DPS **ID Scope** and device **Registration ID** before installing IoT Edge on your device.
83+
1. Open a PowerShell window in administrator mode. Be sure to use an AMD64 session of PowerShell when installing IoT Edge, not PowerShell (x86).
6584

66-
[Install and automatically provision IoT Edge](how-to-install-iot-edge-windows.md#option-2-install-and-automatically-provision)
85+
1. The **Deploy-IoTEdge** command checks that your Windows machine is on a supported version, turns on the containers feature, and then downloads the moby runtime and the IoT Edge runtime. The command defaults to using Windows containers.
86+
87+
```powershell
88+
. {Invoke-WebRequest -useb https://aka.ms/iotedge-win} | Invoke-Expression; `
89+
Deploy-IoTEdge
90+
```
91+
92+
1. At this point, IoT Core devices may restart automatically. Other Windows 10 or Windows Server devices may prompt you to restart. If so, restart your device now. Once your device is ready, run PowerShell as an administrator again.
93+
94+
1. The **Initialize-IoTEdge** command configures the IoT Edge runtime on your machine. The command defaults to manual provisioning with Windows containers. Use the `-Dps` flag to use the Device Provisioning Service instead of manual provisioning.
95+
96+
Replace the placeholder values for `{scope_id}` and `{registration_id}` with the data you collected earlier.
97+
98+
```powershell
99+
. {Invoke-WebRequest -useb https://aka.ms/iotedge-win} | Invoke-Expression; `
100+
Initialize-IoTEdge -Dps -ScopeId {scope ID} -RegistrationId {registration ID}
101+
```
67102

68103
## Verify successful installation
69104

@@ -77,7 +112,6 @@ Get-Service iotedge
77112

78113
Examine service logs from the last 5 minutes.
79114

80-
81115
```powershell
82116
. {Invoke-WebRequest -useb aka.ms/iotedge-win} | Invoke-Expression; Get-IoTEdgeLog
83117
```

0 commit comments

Comments
 (0)