azure-iot-sdk-c/provisioning_service_client/samples/prov_sc_enrollment_group_sa...
Cristian Pop bba2267a15
Adding -Wstrict-prototypes gate validation (#2251)
* Partial fixes for -Wstrict-prototypes

* Adding strict-prototypes gate check.

* Updating submodules.

* Update CMakeLists.txt

Co-authored-by: Eric Wolz <ericwol@microsoft.com>

Co-authored-by: Eric Wolz <ericwol@microsoft.com>
2022-03-02 22:37:31 +00:00
..
CMakeLists.txt Added OpenSSL compatibility for samples 2018-03-19 21:45:07 +00:00
prov_sc_enrollment_group_sample.c Adding -Wstrict-prototypes gate validation (#2251) 2022-03-02 22:37:31 +00:00
readme.md typos | readme sanitation | remove en-us from links (#2162) 2021-11-22 19:09:53 +00:00

readme.md

Provisioning Service Client Sample for Enrollment Group

Overview

This is a quick tutorial with the steps to create, update, get, and delete an Enrollment Group on the Microsoft Azure IoT Hub Device Provisioning Service using the C SDK.

References

Source Code

How to run the sample on Linux or Windows

  1. Clone the C SDK repository

  2. Compile the C SDK as shown here, using the -Duse_prov_client=ON flag.

  3. Edit provisioning_enrollment_group_sample.c to add your provisioning service information:

    1. Replace the [Connection String] with the Provisioning Connection String copied from your Device Provisiong Service on the Portal.
      const char* connectionString = "[Connection String]";
      
    2. Replace the [Group Id] with your chosen Group Id.
    3. For using a Signing Certificate (as shown in the sample):
      1. Replace the [Signing Certificate] with your signing certificate. You can use a physical device with DICE, or use a certificate you generate yourself. One possible way to do this is to use the included CA Certificates Tool.
        const char* signingCertificate = "[Signing Certificate]";
        
        Note that a certificate format can be just the Base 64 encoding, or can include the -----BEGIN CERTIFICATE----- and -----END CERTIFICATE----- tags, either works.
    4. For using a CA Certificate Reference (not shown in this sample):
      1. Define a variable caReference, and set it to the name of the CA Certificate you have generated on the Portal.

        const char* caReference = "[CA Reference]"
        
      2. Replace the Signing Certificate x509 Attestation Mechanism in the sample with a CA Reference x509 Attestation Mechanism

        Replace

        if ((am_handle = attestationMechanism_createWithX509SigningCert(signingCertificate, NULL)) == NULL)
        {
            printf("Failed calling attestationMechanism_createX509SigningCert\n");
            result = MU_FAILURE;
        }
        

        With

        if ((am_handle = attestationMechanism_createWithX509CAReference(caReference, NULL)) == NULL)
        {
            printf("Failed calling attestationMechansim_createX509CAReference\n");
            result = MU_FAILURE;
        }
        
  4. Build as shown here and run the sample.