AWS IoT Device SDK C:
Fleet Provisioning
AWS IoT Fleet Provisioning
|
Return to main page ↑ |
User-facing functions of the Provisioning library. More...
#include "iot_config.h"
#include "types/aws_iot_provisioning_types.h"
#include "types/iot_mqtt_types.h"
Go to the source code of this file.
Functions | |
AwsIotProvisioningError_t | AwsIotProvisioning_Init (uint32_t mqttTimeout) |
One-time initialization function for the Provisioning library. More... | |
AwsIotProvisioningError_t | AwsIotProvisioning_CreateKeysAndCertificate (IotMqttConnection_t connection, uint32_t flags, uint32_t timeoutMs, const AwsIotProvisioningCreateKeysAndCertificateCallbackInfo_t *pResponseCallback) |
Requests a new public-private key pair and certificate for the device from AWS IoT Core and invokes the provided user-callback with the response from the server. More... | |
AwsIotProvisioningError_t | AwsIotProvisioning_CreateCertificateFromCsr (IotMqttConnection_t connection, IotMqttQos_t operationQos, const char *pCertificateSigningRequest, size_t csrLength, uint32_t timeoutMs, const AwsIotProvisioningCreateCertFromCsrCallbackInfo_t *pResponseCallback) |
Requests the AWS IoT Core service for a certificate by sending a Certificate-Signing Request, and invokes the provided user-defined response handler with the response it receives from the server. More... | |
AwsIotProvisioningError_t | AwsIotProvisioning_RegisterThing (IotMqttConnection_t connection, const AwsIotProvisioningRegisterThingRequestInfo_t *pProvisioningDataInfo, uint32_t timeoutMs, const AwsIotProvisioningRegisterThingCallbackInfo_t *pResponseCallback) |
Requests the AWS IoT Core service to register the device, and invokes the user-defined callback with the response it receives from the server. More... | |
void | AwsIotProvisioning_Cleanup (void) |
One-time deinitialization function for the Provisioning library. More... | |
const char * | AwsIotProvisioning_strerror (AwsIotProvisioningError_t status) |
Returns a string that describes an AwsIotProvisioningError_t. More... | |
User-facing functions of the Provisioning library.
AwsIotProvisioningError_t AwsIotProvisioning_Init | ( | uint32_t | mqttTimeout | ) |
One-time initialization function for the Provisioning library.
This function performs internal setup of the Provisioning library. It must be called once before calling any other Fleet Provisioning function.
[in] | mqttTimeout | The amount of time (in milliseconds) that the Provisioning library will wait for MQTT operations. Optional; set this to 0 to use AWS_IOT_PROVISIONING_DEFAULT_MQTT_TIMEOUT_MS. |
AwsIotProvisioningError_t AwsIotProvisioning_CreateKeysAndCertificate | ( | IotMqttConnection_t | connection, |
uint32_t | flags, | ||
uint32_t | timeoutMs, | ||
const AwsIotProvisioningCreateKeysAndCertificateCallbackInfo_t * | pResponseCallback | ||
) |
Requests a new public-private key pair and certificate for the device from AWS IoT Core and invokes the provided user-callback with the response from the server.
[in] | connection | The MQTT connection handle to the user AWS IoT account, which will be used for communicating with the server for creating new device credentials. |
[in] | flags | The flags for configuring the behavior of the API. See the options available in the aws_iot_provisioning_types.h file. |
[in] | timeoutMs | The timeout (in milliseconds) for a response from the server. If there is a timeout, this function returns AWS_IOT_PROVISIONING_TIMEOUT. |
[in] | pResponseCallback | The user-defined callback that will be invoked with the response from the server, whether new credentials for the device in case of success, OR error response in case of server rejection of the credentials generation request. The callback should be defined appropriately for storing the credentials provided by the server on the device. |
AwsIotProvisioningError_t AwsIotProvisioning_CreateCertificateFromCsr | ( | IotMqttConnection_t | connection, |
IotMqttQos_t | operationQos, | ||
const char * | pCertificateSigningRequest, | ||
size_t | csrLength, | ||
uint32_t | timeoutMs, | ||
const AwsIotProvisioningCreateCertFromCsrCallbackInfo_t * | pResponseCallback | ||
) |
Requests the AWS IoT Core service for a certificate by sending a Certificate-Signing Request, and invokes the provided user-defined response handler with the response it receives from the server.
pCertificateSigningRequest
input to this function. An effective way to mitigate that threat is to store all device private keys in a secure element. Another threat is the unauthorized reuse of the device private key, and/or of the contents of pCertificateSigningRequest
, in order to clone the device. An effective way to mitigate that threat is to audit, in the cloud, the use of each device private key. For example, if a device private key is reused, your cloud app (through Fleet Provisioning Hooks) could log an audit event for operator follow-up, and/or initiate a workflow for revoking the previous certificate(s) issued to that key.[in] | connection | The MQTT connection handle that will be used to communicate with AWS IoT Core for the Certificate-Signing Request. |
[in] | operationQos | The Quality of Service (QoS) level for the MQTT publish/subscribe communication with the server. |
[in] | pCertificateSigningRequest | The PEM encoded string for the Certificate-Signing Request. |
[in] | csrLength | The length of the Certificate-Signing Request string. |
[in] | timeoutMs | The timeout (in milliseconds) for a response from the server. If there is a timeout, this function returns AWS_IOT_PROVISIONING_TIMEOUT. |
[in] | pResponseCallback | The user-defined callback that will be invoked with the server's response to the CSR request. The server can respond either with the new certificate information (in case of request acceptance) OR with error (in case of request rejection). |
AwsIotProvisioningError_t AwsIotProvisioning_RegisterThing | ( | IotMqttConnection_t | connection, |
const AwsIotProvisioningRegisterThingRequestInfo_t * | pProvisioningDataInfo, | ||
uint32_t | timeoutMs, | ||
const AwsIotProvisioningRegisterThingCallbackInfo_t * | pResponseCallback | ||
) |
Requests the AWS IoT Core service to register the device, and invokes the user-defined callback with the response it receives from the server.
For registering the device, the service is expected to provide the new certificate, and optionally set up the Thing, Attributes and other cloud settings based on the fleet provisioning template and device context information that are passed to the API.
Also, the AWS IoT account being connected to for registering the device SHOULD have a fleet provisioning template created, whose template name should be passed to this API for requesting device registration.
[in] | connection | The MQTT connection handle to the user AWS IoT account that will be used for registering the device. |
[in] | pProvisioningDataInfo | The data (including the certificate) that needs to be sent to the server for registering the device. |
[in] | timeoutMs | The timeout (in milliseconds) for a response from the server. If there is a timeout, this function returns AWS_IOT_PROVISIONING_TIMEOUT. |
[in] | pResponseCallback | The user-defined functor that will be called with the response received from the server, whether post-provisioning data in case of success OR error message in case of server rejection of registration request. |
void AwsIotProvisioning_Cleanup | ( | void | ) |
One-time deinitialization function for the Provisioning library.
This function frees resources taken in AwsIotProvisioning_Init. It should be called to clean up the Provisioning library. After this function returns, AwsIotProvisioning_Init must be called again before calling any other Provisioning function.
const char* AwsIotProvisioning_strerror | ( | AwsIotProvisioningError_t | status | ) |
Returns a string that describes an AwsIotProvisioningError_t.
Like POSIX's strerror
, this function returns a string describing a return code. In this case, the return code is a Provisioning library error code, status
.
The string returned by this function MUST be treated as read-only: any attempt to modify its contents may result in a crash. Therefore, this function is limited to usage in logging.
[in] | status | The status to describe. |
status
.