简体   繁体   English

AWS IoT-如何指定证书路径(Swagger + NodeJS)

[英]AWS IoT - how to specify the certificate path (Swagger + NodeJS)

I am working with AWS IoT, and try to publish a topic on AWS IoT. 我正在使用AWS IoT,并尝试发布有关AWS IoT的主题。

What I have done: 我做了什么:

  • Register a thing and setup policies (download 4 certificate files) from AWS IoT 从AWS IoT注册事物和设置策略(下载4个证书文件)
  • install sdk with npm ( https://github.com/aws/aws-iot-device-sdk-js ) 使用npm安装sdk( https://github.com/aws/aws-iot-device-sdk-js
  • Copy all certificate files (4 files) to a folder "cert", same level with app.js 将所有证书文件(4个文件)复制到文件夹“ cert”,与app.js处于同一级别
  • In Swagger controllers, create a file js and copy sample code as link above. 在Swagger控制器中,创建文件js并复制示例代码作为上面的链接。
  • In file js, update code as below 在文件js中,更新代码如下

    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' }); var device = awsIot.device({keyPath:'cert / xxxxxx-private.pem.key',certPath:'cert / xxxxxx-certificate.pem.crt',caPath:'cert / rootCA.pem',clientId:'TestIoT ”,主机:“ xxxxxxxx.amazonaws.com”});

What error I received : 我收到什么错误:

Invalid "keyPath" option supplied. 提供了无效的“ keyPath”选项。 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) 在module.exports(/var/app/current/node_modules/aws-iot-device-sdk/common/lib/tls-reader.js:92:13)在新DeviceClient(/ var / app / current / node_modules / aws) -iot-device-sdk / device / index.js:416:7)位于Object.DeviceClient [作为设备](/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. 请给我一些建议,如何正确指定路径。

Try relative paths: 尝试相对路径:

'./cert/xxxxxx-private.pem.key'

It is the same path but adding "./" at the start. 这是相同的路径,但在开头添加“ ./”。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM