I am working with AWS IoT, and try to publish a topic on AWS IoT.
What I have done:
- Register a thing and setup policies (download 4 certificate files) from AWS IoT
- install sdk with npm (https://github.com/aws/aws-iot-device-sdk-js)
- Copy all certificate files (4 files) to a folder "cert", same level with app.js
- In Swagger controllers, create a file js and copy sample code as link above.
In file js, update code as below
var device = awsIot.device({ keyPath: 'cert/xxxxxx-private.pem.key', certPath: 'cert/xxxxxx-certificate.pem.crt', caPath: 'cert/rootCA.pem', clientId: 'TestIoT', host: 'xxxxxxxx.amazonaws.com' });
What error I received :
Invalid "keyPath" option supplied. at module.exports (/var/app/current/node_modules/aws-iot-device-sdk/common/lib/tls-reader.js:92:13) at new DeviceClient (/var/app/current/node_modules/aws-iot-device-sdk/device/index.js:416:7) at Object.DeviceClient [as device] (/var/app/current/node_modules/aws-iot-device-sdk/device/index.js:201:14)
As I understand, the path is not specified correctly. Please give me some advices how to specify the path correctly.