From cd75b5c7dd7d286c5b8a9565ecf27f3467b5706b Mon Sep 17 00:00:00 2001 From: brentru Date: Tue, 15 Oct 2019 11:46:42 -0400 Subject: [PATCH] use files in examples, instead of CERTIFICATES.PY --- examples/aws_iot_shadows.py | 16 ++++++++++++---- examples/aws_iot_simpletest.py | 16 ++++++++++++---- 2 files changed, 24 insertions(+), 8 deletions(-) diff --git a/examples/aws_iot_shadows.py b/examples/aws_iot_shadows.py index a26217c..12069ea 100644 --- a/examples/aws_iot_shadows.py +++ b/examples/aws_iot_shadows.py @@ -18,12 +18,20 @@ except ImportError: print("WiFi secrets are kept in secrets.py, please add them there!") raise -# Get device certificate and private key from a certificates.py file +# Get device certificate try: - from certificates import DEVICE_CERT, DEVICE_KEY + with open("aws_cert.pem.crt", "rb") as f: + DEVICE_CERT = f.read() except ImportError: - print("Certificate and private key data is kept in certificates.py, \ - please add them there!") + print("Certificate (aws_cert.pem.crt) not found on CIRCUITPY filesystem.") + raise + +# Get device private key +try: + with open("private.pem.key", "rb") as f: + DEVICE_KEY = f.read() +except ImportError: + print("Certificate (private.pem.key) not found on CIRCUITPY filesystem.") raise # If you are using a board with pre-defined ESP32 Pins: diff --git a/examples/aws_iot_simpletest.py b/examples/aws_iot_simpletest.py index 58e9279..09d41a4 100644 --- a/examples/aws_iot_simpletest.py +++ b/examples/aws_iot_simpletest.py @@ -18,12 +18,20 @@ except ImportError: print("WiFi secrets are kept in secrets.py, please add them there!") raise -# Get device certificate and private key from a certificates.py file +# Get device certificate try: - from certificates import DEVICE_CERT, DEVICE_KEY + with open("aws_cert.pem.crt", "rb") as f: + DEVICE_CERT = f.read() except ImportError: - print("Certificate and private key data is kept in certificates.py, \ - please add them there!") + print("Certificate (aws_cert.pem.crt) not found on CIRCUITPY filesystem.") + raise + +# Get device private key +try: + with open("private.pem.key", "rb") as f: + DEVICE_KEY = f.read() +except ImportError: + print("Certificate (private.pem.key) not found on CIRCUITPY filesystem.") raise # If you are using a board with pre-defined ESP32 Pins: