Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -60,3 +60,7 @@ target/

#Ipython Notebook
.ipynb_checkpoints

# key file
*.pem
*.key
8 changes: 5 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,11 +3,13 @@
## Platforms supported

I've tested the certificate creation commands only on Windows using the AWS CLI. I think they should work on the AWS CLI of other platforms.
If you need to AWS CLI set-up please check this link: [https://docs.aws.amazon.com/cli/latest/userguide/cli-configure-quickstart.html]

My python programs run perfectly on:
This Python programs run perfectly on:
- Raspberry PI 2 with Raspbian Jessie and Python 2.7
- Debian Jessie virtual machine with Python 2.7
- Windows with Python 3.4 installed by Conda
- Ubuntu 20.04 with Python 3.8 installed by Conda

## Create a thing, certifcate, keys and attaching them to enable usage of AWS IoT hub

Expand All @@ -23,13 +25,13 @@ aws iot list-things
```
create certificate and keys:
```
aws iot create-keys-and-certificate --set-as-active --certificate-pem-outfile cert.pem --public-key-outfile publicKey.pem --private-key-outfile privkey.pem
aws iot create-keys-and-certificate --set-as-active --certificate-pem-outfile myThingName.cert.pem --public-key-outfile myThingName.public.key --private-key-outfile myThingName.private.key
```
take note of the **certificate-arn** in the output or, if you forgot to copy the **certificate-arn** you can get it listing the certificates with:
```
aws iot list-certificates
```
download root certificate from [this URL](https://www.symantec.com/content/en/us/enterprise/verisign/roots/VeriSign-Class%203-Public-Primary-Certification-Authority-G5.pem) using your browser and save it with filename: **aws-iot-rootCA.crt**
Download root certificate from [this URL](https://www.amazontrust.com/repository/AmazonRootCA1.pem) using your browser and save it with filename: **AmazonRootCA1.pem**

create a policy from the file provided:
```
Expand Down
6 changes: 3 additions & 3 deletions awsiotpub.py
Original file line number Diff line number Diff line change
Expand Up @@ -38,9 +38,9 @@ def on_message(client, userdata, msg):
awsport = 8883
clientId = "myThingName"
thingName = "myThingName"
caPath = "aws-iot-rootCA.crt"
certPath = "cert.pem"
keyPath = "privkey.pem"
caPath = "AmazonRootCA1.pem"
certPath = "myThingName.cert.pem"
keyPath = "myThingName.private.key"

mqttc.tls_set(caPath, certfile=certPath, keyfile=keyPath, cert_reqs=ssl.CERT_REQUIRED, tls_version=ssl.PROTOCOL_TLSv1_2, ciphers=None)

Expand Down
6 changes: 3 additions & 3 deletions awsiotsub.py
Original file line number Diff line number Diff line change
Expand Up @@ -35,9 +35,9 @@ def on_message(client, userdata, msg):
awsport = 8883
clientId = "myThingName"
thingName = "myThingName"
caPath = "aws-iot-rootCA.crt"
certPath = "cert.pem"
keyPath = "privkey.pem"
caPath = "AmazonRootCA1.pem"
certPath = "myThingName.cert.pem"
keyPath = "myThingName.private.key"

mqttc.tls_set(caPath, certfile=certPath, keyfile=keyPath, cert_reqs=ssl.CERT_REQUIRED, tls_version=ssl.PROTOCOL_TLSv1_2, ciphers=None)

Expand Down