IoT in Node.js - example flow

I’m trying to write an E2E test for a simple Thing provisioning flow.
My Node.js application creates a Thing, assigns it with certificates and then returns these certificates to the test, which attempts to connect to MQTT.

The Node.js calls CreateKeysAndCertificate, but it seems like the certificate created is not a valid PEM format.

On the other side, the test attempts to use the v2 js SDK which uses AWSCRT under the hood, and does not manage to connect, even if I not try to send a cert at all, due to TLS handshake issues.

I see only a Pyhton example in the localstack-pro-samples repo, which seems to be very far from the Node.js APIs.

Can you refer me to a working example that uses Node.js?
Alternately, what might I be missing? why would Localstack create bad certificates?


This looks like a bug. Could you please file a bug report on GitHub? Please also include the steps and code samples to reproduce this.

1 Like

Created bug: IoT CreateKeysAndCertificate creates invalid PEM certificates · Issue #7366 · localstack/localstack · GitHub

1 Like

Hi @viren
Now that localstack creates valid credentials I’m stuck on TLS negotiation.
I’m not very experienced with TLS, so it’s hard for me to understand exactly what’s going on here. I created a repo reproducing the issue: GitHub - electricmonk/localstack-iot-test

Can you please help? ideally you could check if there’s a step I’m missing, and assert that in your dev env you’re able to make the test work.


Hi @electricmonk,

We do now provide more details on Network troubleshooting | Docs (, also steps how to provide Custom TLS certificates | Docs (