Skip to content

Commit eae80d2

Browse files
authored
Merge pull request #91 from arduino/tests_micropy_key_cert
tests: Add key-cert test for MicroPython.
2 parents 4158871 + 09b8948 commit eae80d2

File tree

3 files changed

+19
-5
lines changed

3 files changed

+19
-5
lines changed

.github/workflows/client-test.yml

+10-2
Original file line numberDiff line numberDiff line change
@@ -63,7 +63,7 @@ jobs:
6363
pip install --user dist/arduino_iot_cloud-*.whl
6464
pip install --target=${HOME}/.micropython/lib dist/arduino_iot_cloud-*.whl
6565
66-
- name: '🔑 Configure soft crypto device'
66+
- name: '🔑 Configure secure element'
6767
env:
6868
KEY_PEM: ${{ secrets.KEY_PEM }}
6969
CERT_PEM: ${{ secrets.CERT_PEM }}
@@ -92,7 +92,6 @@ jobs:
9292
run: |
9393
python tests/ci.py --file-auth
9494
95-
9695
- name: '☁️ Connect to IoT cloud (CPython / Crypto Auth / Async)'
9796
env:
9897
DEVICE_ID: ${{ secrets.DEVICE_ID2 }}
@@ -118,3 +117,12 @@ jobs:
118117
export PATH="${HOME}/cache/bin:${PATH}"
119118
micropython -c "import sys; print(sys.path)"
120119
micropython tests/ci.py --basic-auth --sync
120+
121+
- name: '☁️ Connect to IoT cloud (MicroPython / Key-Cert Auth / Async)'
122+
env:
123+
DEVICE_ID: ${{ secrets.DEVICE_ID2 }}
124+
SECRET_KEY: ${{ secrets.SECRET_KEY }}
125+
run: |
126+
export PATH="${HOME}/cache/bin:${PATH}"
127+
micropython -c "import sys; print(sys.path)"
128+
micropython tests/ci.py --file-auth

tests/ci.py

+4-3
Original file line numberDiff line numberDiff line change
@@ -75,12 +75,13 @@ def wdt_task(client, args, ts=[None]):
7575
)
7676
elif args.file_auth:
7777
import ssl
78+
fmt = "der" if sys.implementation.name == "micropython" else "pem"
7879
client = ArduinoCloudClient(
7980
device_id=os.getenv("DEVICE_ID"),
8081
ssl_params={
81-
"keyfile": "key.pem",
82-
"certfile": "cert.pem",
83-
"ca_certs": "ca-root.pem",
82+
"keyfile": f"key.{fmt}",
83+
"certfile": f"cert.{fmt}",
84+
"ca_certs": f"ca-root.{fmt}",
8485
"cert_reqs": ssl.CERT_REQUIRED,
8586
},
8687
sync_mode=args.sync,

tests/ci.sh

+5
Original file line numberDiff line numberDiff line change
@@ -57,4 +57,9 @@ ci_configure_softhsm() {
5757
softhsm2-util --init-token --slot 0 --label "arduino" --pin 1234 --so-pin 1234
5858
p11tool --provider=${PROVIDER} --login --set-pin=1234 --write ${TOKEN_URI} --load-privkey key.pem --label "mykey"
5959
p11tool --provider=${PROVIDER} --login --set-pin=1234 --write ${TOKEN_URI} --load-certificate cert.pem --label "mycert"
60+
61+
# Convert to DER for MicroPython.
62+
openssl ec -in key.pem -out key.der -outform DER
63+
openssl x509 -in cert.pem -out cert.der -outform DER
64+
openssl x509 -in ca-root.pem -out ca-root.der -outform DER
6065
}

0 commit comments

Comments
 (0)