Skip to content

Commit bd7e1de

Browse files
committed
Fix script. Remove locale slug
1 parent 70a9c0e commit bd7e1de

File tree

2 files changed

+32
-50
lines changed

2 files changed

+32
-50
lines changed

articles/iot-edge/how-to-provision-devices-at-scale-linux-tpm.md

Lines changed: 31 additions & 49 deletions
Original file line numberDiff line numberDiff line change
@@ -178,64 +178,46 @@ Sign in to your device, and install the `tpm2-tools` package.
178178
# [Ubuntu / Debian / Raspberry Pi OS](#tab/ubuntu+debian+rpios)
179179

180180

181-
```bash
182-
sudo apt-get install tpm2-tools
183-
```
181+
```bash
182+
sudo apt-get install tpm2-tools
183+
```
184184

185185
# [Red Hat Enterprise Linux](#tab/rhel)
186186

187187

188-
```bash
189-
sudo yum install tpm2-tools
190-
```
188+
```bash
189+
sudo yum install tpm2-tools
190+
```
191191

192192
---
193193

194194
Run the following script to read the endorsement key, creating one if it does not already exist.
195195

196-
```bash
197-
#!/bin/sh
198-
if [ "$USER" != "root" ]; then
199-
SUDO="sudo "
200-
fi
201-
202-
$SUDO tpm2_readpublic -Q -c 0x81010001 -o ek.pub 2> /dev/null
203-
if [ $? -gt 0 ]; then
204-
# Create the endorsement key (EK)
205-
$SUDO tpm2_createek -c ek.ctx > /dev/null
206-
$SUDO tpm2_evictcontrol -c ek.ctx 0x81010001 > /dev/null
207-
$SUDO tpm2_readpublic -c 0x81010001 -o ek.pub > /dev/null
208-
$SUDO tpm2_flushcontext -t > /dev/null
209-
210-
# Create a storage root key (SRK)
211-
$SUDO tpm2_startauthsession --policy-session -S session.ctx > /dev/null
212-
$SUDO tpm2_policysecret -S session.ctx -c 0x4000000B > /dev/null
213-
$SUDO tpm2_create -C 0x81010001 \
214-
-G rsa2048 \
215-
-a 'restricted|decrypt|fixedtpm|fixedparent|sensitivedataorigin|userwithauth' \
216-
-u srk.pub -r srk.priv \
217-
-P session:session.ctx > /dev/null
218-
$SUDO tpm2_flushcontext --transient-object > /dev/null
219-
220-
# store the key
221-
$SUDO tpm2_startauthsession -S session.ctx --policy-session > /dev/null
222-
$SUDO tpm2_policysecret -S session.ctx -c 0x4000000B > /dev/null
223-
$SUDO tpm2_load -C 0x81010001 \
224-
-u srk.pub -r srk.priv \
225-
-P session:session.ctx \
226-
-c srk.ctx > /dev/null
227-
228-
# make the SRK persistent
229-
$SUDO tpm2_evictcontrol -c srk.ctx 0x81000001 > /dev/null
230-
231-
# clean up
232-
$SUDO rm session.ctx srk.pub srk.priv srk.ctx ek.ctx 2> /dev/null
233-
fi
234-
235-
printf "Gathering the registration information...\n\nRegistration Id:\n%s\n\nEndorsement Key:\n%s\n" $(sha256sum -b ek.pub | cut -d' ' -f1 | sed -e 's/[^[:alnum:]]//g') $(base64 -w0 ek.pub)
236-
237-
$SUDO rm ek.pub 2> /dev/null
238-
```
196+
```bash
197+
#!/bin/sh
198+
if [ "$USER" != "root" ]; then
199+
SUDO="sudo "
200+
fi
201+
202+
$SUDO tpm2_readpublic -Q -c 0x81010001 -o ek.pub 2> /dev/null
203+
if [ $? -gt 0 ]; then
204+
# Create the endorsement key (EK)
205+
$SUDO tpm2_createek -c 0x81010001 -G rsa -u ek.pub
206+
207+
# Create the storage root key (SRK)
208+
$SUDO tpm2_createprimary -Q -C o -c srk.ctx > /dev/null
209+
210+
# make the SRK persistent
211+
$SUDO tpm2_evictcontrol -c srk.ctx 0x81000001 > /dev/null
212+
213+
# open transient handle space for the TPM
214+
$SUDO tpm2_flushcontext -t > /dev/null
215+
fi
216+
217+
printf "Gathering the registration information...\n\nRegistration Id:\n%s\n\nEndorsement Key:\n%s\n" $(sha256sum -b ek.pub | cut -d' ' -f1 | sed -e 's/[^[:alnum:]]//g') $(base64 -w0 ek.pub)
218+
$SUDO rm ek.pub srk.ctx 2> /dev/null
219+
220+
```
239221

240222
The output window displays the device's **Endorsement key** and a unique **Registration ID**. Copy these values for use later when you create an individual enrollment for your device in the device provisioning service.
241223

articles/iot-edge/how-to-provision-devices-at-scale-linux-x509.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@ The tasks are as follows:
2525
Using X.509 certificates as an attestation mechanism is an excellent way to scale production and simplify device provisioning. Typically, X.509 certificates are arranged in a certificate chain of trust. Starting with a self-signed or trusted root certificate, each certificate in the chain signs the next lower certificate. This pattern creates a delegated chain of trust from the root certificate down through each intermediate certificate to the final "leaf" certificate installed on a device.
2626

2727
> [!TIP]
28-
> If your device has a Hardware Security Module (HSM) such as a TPM 2.0, then we recommend storing the X.509 keys securely in the HSM. Learn more about how to implement the zero-touch provisioning at scale described in [this blueprint](https://azure.microsoft.com/en-us/blog/the-blueprint-to-securely-solve-the-elusive-zerotouch-provisioning-of-iot-devices-at-scale) with the [https://aka.ms/iotedge-tpm2cloud](https://aka.ms/iotedge-tpm2cloud) sample.
28+
> If your device has a Hardware Security Module (HSM) such as a TPM 2.0, then we recommend storing the X.509 keys securely in the HSM. Learn more about how to implement the zero-touch provisioning at scale described in [this blueprint](https://azure.microsoft.com/blog/the-blueprint-to-securely-solve-the-elusive-zerotouch-provisioning-of-iot-devices-at-scale) with the [https://aka.ms/iotedge-tpm2cloud](https://aka.ms/iotedge-tpm2cloud) sample.
2929
3030
## Prerequisites
3131

0 commit comments

Comments
 (0)