aws / aws-iot-device-sdk-js

SDK for connecting to AWS IoT from a device using JavaScript/Node.js
Apache License 2.0
965 stars 385 forks source link

Invalid "keyPath" option supplied. #387

Closed usman-whizpool closed 3 years ago

usman-whizpool commented 3 years ago

/node_modules/aws-iot-device-sdk/common/lib/tls-reader.js:92 throw new Error(exceptions.INVALID_KEY_PATH_OPTION); ^

Error: Invalid "keyPath" option supplied.

I am having this error please help me out. I am trying to use "aws-iot-device-sdk" to control the appliances (lights , fans) in nodejs

var awsIot = require('aws-iot-device-sdk');

Thanks

bretambrose commented 3 years ago

Looking at tls-reader.js, it appears to be checking the path you supplied in your configuration and it's not a valid path to a key file.

usman-whizpool commented 3 years ago

The path is valid, files exists at path given

usman-whizpool commented 3 years ago

resolved issue with following code.

const thingShadows = awsIot.thingShadow({ keyPath: (dirname + '/cert_files/private.pem.key'), certPath: (__dirname + '/cert_files/certificate.pem.crt'), caPath: (dirname + '/cert_files/AmazonRootCA1.pem'), host: 'xxxxxxxxxx-xxxxxx-1.amazonaws.com', clientId: 'xxxxxxxx', region: 'xxxxxxx', });

I think it expect complete path to the file. appending __dirname at start of the folder path worked

github-actions[bot] commented 3 years ago

⚠️COMMENT VISIBILITY WARNING⚠️

Comments on closed issues are hard for our team to see. If you need more assistance, please either tag a team member or open a new issue that references this one. If you wish to keep having a conversation with other community members under this issue feel free to do so.