尝试让我的node.js IOT示例工作,但不确定我需要设置哪些配置传递给我的thingShadow构造函数awsIot.thingShadow(config)
这是我从AWS仪表板获取的示例配置
{
"host": "foo.iot.us-east-1.amazonaws.com",
"port": 8883,
"clientId": "bar",
"thingName": "bar",
"caCert": "root-CA.crt",
"clientCert": "bar-certificate.pem.crt",
"privateKey": "bar-private.pem.key"
}
然而,这是我根据sdk自述文件设置的构造函数
{
keyPath: 'bar-private.pem.key',
certPath: 'bar-certificate.pem.crt',
caCert: "root-CA.crt",
clientId: 'bar'
}
我收到错误
events.js:141 扔掉//未处理的'错误'事件 ^
Error: unable to get local issuer certificate
at Error (native)
at TLSSocket.<anonymous> (_tls_wrap.js:1017:38)
at emitNone (events.js:67:13)
at TLSSocket.emit (events.js:166:7)
at TLSSocket._init.ssl.onclienthello.ssl.oncertcb.TLSSocket._finishInit (_tls_wrap.js:582:8)
at TLSWrap.ssl.onclienthello.ssl.oncertcb.ssl.onnewsession.ssl.onhandshakedone (_tls_wrap.js:424:38)
caCert基于什么?是我在本地路径中拥有的证书吗?如果是这样,我从哪里获取它,仪表板作为下载地点?我是否为privateKey发送了正确的证书文件?
答案 0 :(得分:2)
所以问题是root-CA.crt文件。我从aws库的node_modules目录中找到了我的,但是无效。
如本文http://docs.aws.amazon.com/iot/latest/developerguide/iot-device-sdk-node.html
所述