GithubHelp home page GithubHelp logo

keivank1 / aws-create-thing-boto3 Goto Github PK

View Code? Open in Web Editor NEW
13.0 0.0 13.0 2 KB

Create AWS IoT Thing using python and boto3

Python 100.00%
aws-iot-device-sdk-python aws-iot-python aws-iot boto3

aws-create-thing-boto3's Introduction

Hi ๐Ÿ‘‹, I'm Keivan

A Software and Hardware Developer Based In Berlin


Checkout my Blog where you can find articles around software development!

Recent Articles

More articles on Cryptiot

Programming Languages & Tools



Keep in Touch

slideshowp2 | Cryptiot slideshowp2 | Stack Overflow slideshowp2 | Stack Exchange slideshowp2 | Linkedin



Checkout some of my industrial projects here, and contact me if you need consulting services for your Software/Hardware projects!

Badges & Stats

Stats

Support

cryptiot



aws-create-thing-boto3's People

Contributors

keivank1 avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

aws-create-thing-boto3's Issues

Unable to Get Local Issuer Certificate

Hey @keivanK1 !

Love the script. Works and pulls down the certificates from AWS IoT like a charm. However, I'm running into an issue actually getting these certificates to work/properly authenticate.

I keep getting "Unable to Get Local Issuer Certificate" when I pull down the certificates and use them to connect to AWS IoT. My hunch is that there is something going on with the x509 certificate. Below is the error is get when I run the jobs-agent.js:

pi@raspberrypi:~$ node jobs-agent.js -k "private.key" -c "root-CA.crt" -H "xxxxxxxxxxxxxxx.iot.us-east-2.amazonaws.com" -p 8883 -T "xxxxxx"

agent connection error { Error: unable to get local issuer certificate
    at TLSSocket.<anonymous> (_tls_wrap.js:1105:38)
    at emitNone (events.js:106:13)
    at TLSSocket.emit (events.js:208:7)
    at TLSSocket._finishInit (_tls_wrap.js:639:8)
    at TLSWrap.ssl.onhandshakedone (_tls_wrap.js:469:38) code: 'UNABLE_TO_GET_ISSUER_CERT_LOCALLY' }

The code I'm running to generate the certificates is below. For some reason, the certificates derived from the script below refuse to connect. Can you let me know if you see anything that looks wonky? Thanks so much for any insight you could provide!

import boto3

client = boto3.client('iot')
thing_name = "boto3_test_unit"

response = client.create_thing(
    thingName=thing_name
)

response = client.create_keys_and_certificate(
    setAsActive=True
)

pub_key = response['keyPair']['PublicKey']
priv_key = response['keyPair']['PrivateKey']
x509 = response['certificatePem']
cert_id = response['certificateId']
cert_arn = response['certificateArn']

with open('public.key', 'w') as outfile:
    outfile.write(pub_key)
with open('private.key', 'w') as outfile:
    outfile.write(priv_key)
with open('root-CA.crt', 'w') as outfile:
    outfile.write(x509)

response = client.attach_policy(
    policyName='MyIoTPolicy',
    target=cert_arn
)

response = client.attach_thing_principal(
    thingName=thing_name,
    principal=cert_arn
)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.