You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: articles/iot-central/core/howto-manage-devices-with-rest-api.md
+392Lines changed: 392 additions & 0 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -547,6 +547,398 @@ The response to this request looks like the following example:
547
547
}
548
548
```
549
549
550
+
## Enrollment groups
551
+
552
+
Enrollment groups are used to manage the device authentication options in your IoT Central application. To learn more, see [Device authentication concepts in IoT Central](concepts-device-authentication.md).
553
+
554
+
To learn how to create and manage enrollment groups in the UI, see [How to connect devices with X.509 certificates to IoT Central Application](how-to-connect-devices-x509.md).
555
+
556
+
## Create an enrollment group
557
+
558
+
### [X509](#tab/X509)
559
+
560
+
When you create an enrollment group for devices that use X.509 certificates, you first need to upload the root or intermediate certificate to your IoT Central application.
561
+
562
+
### Generate root and device certificates
563
+
564
+
In this section, you generate the X.509 certificates you need to connect a device to IoT Central.
565
+
566
+
> [!WARNING]
567
+
> This way of generating X.509 certs is for testing only. For a production environment you should use your official, secure mechanism for certificate generation.
568
+
569
+
1. Navigate to the certificate generator script in the Microsoft Azure IoT SDK for Node.js you downloaded. Install the required packages:
570
+
571
+
```cmd/sh
572
+
cd azure-iot-sdk-node/provisioning/tools
573
+
npm install
574
+
```
575
+
576
+
1. Create a root certificate and then derive a device certificate by running the script:
> A device ID can contain letters, numbers, and the `-` character.
585
+
586
+
These commands produce the following root and the device certificate
587
+
588
+
| filename | contents |
589
+
| -------- | -------- |
590
+
| mytestrootcert_cert.pem | The public portion of the root X.509 certificate |
591
+
| mytestrootcert_key.pem | The private key for the root X.509 certificate |
592
+
| mytestrootcert_fullchain.pem | The entire keychain for the root X.509 certificate. |
593
+
| mytestrootcert.pfx | The PFX file for the root X.509 certificate. |
594
+
| sampleDevice01_cert.pem | The public portion of the device X.509 certificate |
595
+
| sampleDevice01_key.pem | The private key for the device X.509 certificate |
596
+
| sampleDevice01_fullchain.pem | The entire keychain for the device X.509 certificate. |
597
+
| sampleDevice01.pfx | The PFX file for the device X.509 certificate. |
598
+
599
+
Make a note of the location of these files. You need it later.
600
+
601
+
### Generate the base-64 encoded version of the root certificate
602
+
603
+
In the folder on your local machine that contains the certificates you generated, create a file called convert.js and add the following JavaScript content:
### Generate verification code for an X.509 certificate
703
+
704
+
Use the following request to generate a verification code for the primary or secondary X.509 certificate of an enrollment group.
705
+
706
+
If you set `verified` to `false` in the previous request, use the following request to generate a verification code for the primary X.509 certificate in the `myx509eg` enrollment group:
707
+
708
+
```http
709
+
POST https://{your app subdomain}.azureiotcentral.com/api/enrollmentGroups/myx509eg/certificates/primary/generateVerificationCode?api-version=2022-07-31
710
+
```
711
+
712
+
The response to this request looks like the following example:
Run the following command to generate a base-64 encoded version of the certificate:
731
+
732
+
```cmd/sh
733
+
node convert.js verification_cert.pem
734
+
```
735
+
736
+
Make a note of the base-64 encoded version of the certificate. You need it later.
737
+
738
+
### Verify X.509 certificate of an enrollment group
739
+
740
+
Use the following request to verify the primary X.509 certificate of the `myx509eg` enrollment group by providing the certificate with the signed verification code:
741
+
742
+
```http
743
+
POST PUT https://{your app subdomain}.azureiotcentral.com/api/enrollmentGroups/myx509eg/certificates/primary/verify?api-version=2022-07-31
744
+
```
745
+
746
+
The following example shows a request body that verifies an X.509 certificate:
747
+
748
+
```json
749
+
{
750
+
"certificate": "base64-verification-certificate"
751
+
}
752
+
```
753
+
754
+
### Get X.509 certificate of an enrollment group
755
+
756
+
Use the following request to retrieve details of X.509 certificate of an enrollment group from your application:
757
+
758
+
```http
759
+
GET https://{your app subdomain}.azureiotcentral.com/api/enrollmentGroups/myx509eg/certificates/primary?api-version=2022-07-31
760
+
```
761
+
762
+
The response to this request looks like the following example:
Now that you've learned how to manage devices with the REST API, a suggested next step is to [How to control devices with rest api.](howto-control-devices-with-rest-api.md)
0 commit comments