-
Notifications
You must be signed in to change notification settings - Fork 3
Description
I'm not sure if this provisioning method is solely devoted to this TI project, or if it's more general use, but there is a discrepancy in the provisioning lambdas' outputs.
The ACMPCA lambda outputs a JSON payload containing the newly provisioned Thing Certificate and the AWS endpoint. These are returned in the POST response Body.
The Embedded C code used in the project is expecting a JSON Payload containing these two values, however the other provisioning Lambda only outputs a regular string containing the Thing Certificate.
Is it possible to make the iot_core lambda output the same as the ACMPCA lambda? It would be nice to get the JSON payload and parse it to get the endpoint to reduce steps in the manufacturing process as intended by TI.
I've attached the C code of the JSON parsing function. It is simply looking for "certificate" and "endpoint" objects.
`
======== parseJson ========
Parses the Registration server response buffer, that is formatted as JSON.
Retrieves the certificate and endpoint (pointer to the location in the input
JSON string). Expected JSON format:
{
"certificate", "----BEGIN CERTIFICATE .... END CERTIFICATE-----",
"endpoint", "xxxxx.....amazonaws.com"
}
static int parseJson(char *jsonBuffer, int bufferLen, char **pCert,
char **pEndPoint)
{
jsmn_parser parser;
jsmntok_t tokens[5];
jsmntok_t *token;
int status = SUCCESS;
jsmn_init(&parser);
if (jsmn_parse(&parser, jsonBuffer, bufferLen, tokens, 5) <= 0) {
IOT_ERROR("Error while parsing JSON buffer");
status = FAILURE;
}
if (status == SUCCESS) {
token = findToken("certificate", jsonBuffer, tokens);
if (!token) {
status = FAILURE;
IOT_ERROR("Certificate not present in JSON buffer");
}
}
if (status == SUCCESS) {
*pCert = jsonBuffer + token->start;
// add NULL termination to certificate to make it a string
jsonBuffer[token->end] = 0;
token = findToken("endpoint", jsonBuffer, tokens);
if (!token) {
status = FAILURE;
IOT_ERROR("Endpoint not present in JSON buffer");
}
}
if (status == SUCCESS) {
*pEndPoint = jsonBuffer + token->start;
// add NULL termination to endpoint to make it a string
jsonBuffer[token->end] = 0;
}
return (status);
}`
Thank you.