Skip to content

Commit 9976166

Browse files
committed
SelfProvisioning: print error if certificate parsing fails
1 parent 23f6545 commit 9976166

File tree

1 file changed

+11
-10
lines changed

1 file changed

+11
-10
lines changed

examples/utility/SelfProvisioning/SelfProvisioning.ino

Lines changed: 11 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -466,19 +466,20 @@ void ArduinoCertificate(String user_token, String DeviceUuid, String csr) {
466466
JSONVar myObject = JSON.parse(certResponse);
467467
String certZip = JSON.stringify(myObject["compressed"]);
468468
JSONVar myCert = JSON.parse(certZip);
469-
if (myCert.hasOwnProperty("not_before")) {
469+
if (myCert.hasOwnProperty("not_before") &&
470+
myCert.hasOwnProperty("serial") &&
471+
myCert.hasOwnProperty("authority_key_identifier") &&
472+
myCert.hasOwnProperty("signature_asn1_x") &&
473+
myCert.hasOwnProperty("signature_asn1_x")) {
470474
not_before += (const char*) myCert["not_before"];
471-
}
472-
if (myCert.hasOwnProperty("serial")) {
473475
serialNumber += (const char*) myCert["serial"];
474-
}
475-
if (myCert.hasOwnProperty("authority_key_identifier")) {
476476
authorityKeyIdentifier += (const char*) myCert["authority_key_identifier"];
477-
}
478-
if (myCert.hasOwnProperty("signature_asn1_x")) {
479477
signature += (const char*) myCert["signature_asn1_x"];
480-
}
481-
if (myCert.hasOwnProperty("signature_asn1_y")) {
482478
signature += (const char*) myCert["signature_asn1_y"];
479+
} else {
480+
Serial.println("Error parsing cloud certificate");
481+
while (1) {
482+
;
483+
}
483484
}
484-
}
485+
}

0 commit comments

Comments
 (0)