Skip to content

Commit cd75b5c

Browse files
brentrubrentru
brentru
authored and
brentru
committed
use files in examples, instead of CERTIFICATES.PY
1 parent d7e7252 commit cd75b5c

File tree

2 files changed

+24
-8
lines changed

2 files changed

+24
-8
lines changed

examples/aws_iot_shadows.py

Lines changed: 12 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -18,12 +18,20 @@
1818
print("WiFi secrets are kept in secrets.py, please add them there!")
1919
raise
2020

21-
# Get device certificate and private key from a certificates.py file
21+
# Get device certificate
2222
try:
23-
from certificates import DEVICE_CERT, DEVICE_KEY
23+
with open("aws_cert.pem.crt", "rb") as f:
24+
DEVICE_CERT = f.read()
2425
except ImportError:
25-
print("Certificate and private key data is kept in certificates.py, \
26-
please add them there!")
26+
print("Certificate (aws_cert.pem.crt) not found on CIRCUITPY filesystem.")
27+
raise
28+
29+
# Get device private key
30+
try:
31+
with open("private.pem.key", "rb") as f:
32+
DEVICE_KEY = f.read()
33+
except ImportError:
34+
print("Certificate (private.pem.key) not found on CIRCUITPY filesystem.")
2735
raise
2836

2937
# If you are using a board with pre-defined ESP32 Pins:

examples/aws_iot_simpletest.py

Lines changed: 12 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -18,12 +18,20 @@
1818
print("WiFi secrets are kept in secrets.py, please add them there!")
1919
raise
2020

21-
# Get device certificate and private key from a certificates.py file
21+
# Get device certificate
2222
try:
23-
from certificates import DEVICE_CERT, DEVICE_KEY
23+
with open("aws_cert.pem.crt", "rb") as f:
24+
DEVICE_CERT = f.read()
2425
except ImportError:
25-
print("Certificate and private key data is kept in certificates.py, \
26-
please add them there!")
26+
print("Certificate (aws_cert.pem.crt) not found on CIRCUITPY filesystem.")
27+
raise
28+
29+
# Get device private key
30+
try:
31+
with open("private.pem.key", "rb") as f:
32+
DEVICE_KEY = f.read()
33+
except ImportError:
34+
print("Certificate (private.pem.key) not found on CIRCUITPY filesystem.")
2735
raise
2836

2937
# If you are using a board with pre-defined ESP32 Pins:

0 commit comments

Comments
 (0)