Duncan Jones
Duncan Jones

Reputation: 69339

How to update a thing certificate in AWS IoT?

How do I update the certificate of an existing Thing in AWS IoT, assuming I know the thing name and an attribute with the same value? I.e. the thing has name "foo" and attribute "id=foo".

From the limited documentation, I'm assuming I do something like:

Can anyone confirm the correct, most succinct way to do this?

Upvotes: 2

Views: 906

Answers (1)

Duncan Jones
Duncan Jones

Reputation: 69339

I welcome better solutions, but this worked for me:

  1. Call RegisterThing again (same ThingName, same policy, different cert). This seems to attach a new certificate to my thing.
  2. Called ListThingPrincipals, filtering on ThingName. The result will be a list of ARNs representing the certificates associated with the thing, of the form arn:aws:iot:<region>:<account id>:cert/<cert id>.
  3. Iterative through the list, strip out the certificate id and call DescribeCertificate, with the certificate id as parameter.
  4. Compare the result (which includes the PEM form of the certificate) with the new certificate. If it's not a match, this is one of the previous certificates. Consequently, call UpdateCertificate and mark that certificate as INACTIVE.

Upvotes: 3

Related Questions