简体   繁体   English

通过 AWS IOT sdk javascript 配置 AWS IOT 设备

[英]AWS IOT Device provisioning through AWS IOT sdk javascript

I'm trying to provision devices through AWS IOT api calls, i have used the AWS CLI to get CA Certificate and i have also generated X.509 certificate.我正在尝试通过 AWS IOT api 调用来配置设备,我使用 AWS CLI 来获取 CA 证书,并且我还生成了 X.509 证书。 Can anyone please guide me on how to Create Thing and attach certificate through SDK?任何人都可以指导我如何通过 SDK 创建事物并附加证书吗?

I have successfully used the API to create devices on AWS IoT Core by following these steps.我已按照以下步骤成功使用 API 在 AWS IoT Core 上创建设备。 Using the CLI i made CA certificate using rsa key使用 CLI 我使用 rsa 密钥制作了 CA 证书

  • openssl genrsa -out certs/rootCA.key 2048 openssl genrsa -out certs/rootCA.key 2048
  • openssl req -x509 -new -nodes -key certs/rootCA.key -sha256 -days 1024 -out certs/rootCA.pem openssl req -x509 -new -nodes -key certs/rootCA.key -sha256 -days 1024 -out certs/rootCA.pem
  • aws iot get-registration-code (registrationCode used later as a "Common Name") aws iot get-registration-code(registrationCode 稍后用作“通用名称”)
  • openssl genrsa -out certs/verificationCert.key 2048 openssl genrsa -out certs/verificationCert.key 2048

Then i created a CSR然后我创建了一个 CSR

  • openssl req -new -key certs/verificationCert.key -out certs/verificationCert.csr openssl req -new -key certs/verificationCert.key -out certs/verificationCert.csr
  • openssl x509 -req -in certs/verificationCert.csr -CA certs/rootCA.pem -CAkey certs/rootCA.key -CAcreateserial -out certs/verificationCert.crt -days 500 -sha256 openssl x509 -req -in certs/verificationCert.csr -CA certs/rootCA.pem -CAkey certs/rootCA.key -CAcreateserial -out certs/verificationCert.crt -days 500 -sha256

Registered the CA Certificate注册CA证书

  • aws iot register-ca-certificate --ca-certificate file://certs/rootCA.pem --verification-certificate file://certs/verificationCert.crt --allow-auto-registration aws iot register-ca-certificate --ca-certificate file://certs/rootCA.pem --verification-certificate file://certs/verificationCert.crt --allow-auto-registration
  • aws iot update-ca-certificate --certificate-id e3f0a30c3bbd4c9fdbb752cf2717fda21fbd2f8158e5dc0bb320c8bdbabf6295 --new-status ACTIVE aws iot 更新-ca-certificate --certificate-id e3f0a30c3bbd4c9fdbb752cf2717fda21fbd2f8158e5dc0bb320c8bdbabf6295 --new-status ACTIVE

Then i used the the verificationCert.csr for createCertificateFromCsr and used the certificateArn from response in attachPolicy and attachThingPrincipal然后我将 verifyCert.csr 用于 createCertificateFromCsr 并在 attachPolicy 和 attachThingPrincipal 中使用来自响应的certificateArn

You cant connect a device to AWS IoT with an API if you are trying to use HTTPS.如果您尝试使用 HTTPS,则无法使用 API 将设备连接到 AWS IoT。 AWS IoT specifically requires the MQTT broker on AWS IoT Core. AWS IoT 特别需要 AWS IoT Core 上的 MQTT 代理。 Are you using this with a device like RPi?您是否将它与 RPi 之类的设备一起使用?

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

相关问题 AWS IoT Javascript SDK 无法创建客户端 - AWS IoT Javascript SDK can not create client AWS IOT JS 设备 SDK 未连接并不断重新连接 - AWS IOT JS device SDK not connecting and keep on reconnecting again and again 与汇总捆绑在一起时,aws-iot-device-sdk是未定义的 - aws-iot-device-sdk is undefined when bundled with rollup AWS IoT sdk javascript - 无法连接到 AWS(无法从未定义读取 AWS_PROFILE 默认的凭证) - AWS Iot sdk javascript - Cannot connect to AWS (Failed to read credentials for AWS_PROFILE default from undefined) 无法使用本机反应连接到 aws iot 设备 - can not connect to aws iot device with react native Javascript,Tesseract,AWS IoT,Dynamodb和缓冲区 - Javascript, Tesseract, AWS IoT, Dynamodb & Buffers 语法错误:node_modules / aws-iot-device-sdk / thing / index.js中出现意外令牌 - SyntaxError: Unexpected token in node_modules/aws-iot-device-sdk/thing/index.js AWS IoT:ForbiddenException:禁止 - AWS IoT: ForbiddenException: Forbidden 如何将 aws-iot-device-sdk NPM 模块与 Angular 11 一起使用? (它在构建时抛出 fs、path 和 tls 错误) - How can I use aws-iot-device-sdk NPM module with Angular 11 ? (it throws fs, path, & tls errors on build) AWS IoT:在浏览器中订阅主题 - AWS IoT: Subscribe to Topic in Browser
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM