Skip to content

tests: Add key-cert test for MicroPython. #91

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Sep 10, 2024
Merged
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
12 changes: 10 additions & 2 deletions .github/workflows/client-test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,7 @@ jobs:
pip install --user dist/arduino_iot_cloud-*.whl
pip install --target=${HOME}/.micropython/lib dist/arduino_iot_cloud-*.whl

- name: '🔑 Configure soft crypto device'
- name: '🔑 Configure secure element'
env:
KEY_PEM: ${{ secrets.KEY_PEM }}
CERT_PEM: ${{ secrets.CERT_PEM }}
Expand Down Expand Up @@ -92,7 +92,6 @@ jobs:
run: |
python tests/ci.py --file-auth


- name: '☁️ Connect to IoT cloud (CPython / Crypto Auth / Async)'
env:
DEVICE_ID: ${{ secrets.DEVICE_ID2 }}
Expand All @@ -118,3 +117,12 @@ jobs:
export PATH="${HOME}/cache/bin:${PATH}"
micropython -c "import sys; print(sys.path)"
micropython tests/ci.py --basic-auth --sync

- name: '☁️ Connect to IoT cloud (MicroPython / Key-Cert Auth / Async)'
env:
DEVICE_ID: ${{ secrets.DEVICE_ID2 }}
SECRET_KEY: ${{ secrets.SECRET_KEY }}
run: |
export PATH="${HOME}/cache/bin:${PATH}"
micropython -c "import sys; print(sys.path)"
micropython tests/ci.py --file-auth
7 changes: 4 additions & 3 deletions tests/ci.py
Original file line number Diff line number Diff line change
Expand Up @@ -75,12 +75,13 @@ def wdt_task(client, args, ts=[None]):
)
elif args.file_auth:
import ssl
fmt = "der" if sys.implementation.name == "micropython" else "pem"
client = ArduinoCloudClient(
device_id=os.getenv("DEVICE_ID"),
ssl_params={
"keyfile": "key.pem",
"certfile": "cert.pem",
"ca_certs": "ca-root.pem",
"keyfile": f"key.{fmt}",
"certfile": f"cert.{fmt}",
"ca_certs": f"ca-root.{fmt}",
"cert_reqs": ssl.CERT_REQUIRED,
},
sync_mode=args.sync,
Expand Down
5 changes: 5 additions & 0 deletions tests/ci.sh
Original file line number Diff line number Diff line change
Expand Up @@ -57,4 +57,9 @@ ci_configure_softhsm() {
softhsm2-util --init-token --slot 0 --label "arduino" --pin 1234 --so-pin 1234
p11tool --provider=${PROVIDER} --login --set-pin=1234 --write ${TOKEN_URI} --load-privkey key.pem --label "mykey"
p11tool --provider=${PROVIDER} --login --set-pin=1234 --write ${TOKEN_URI} --load-certificate cert.pem --label "mycert"

# Convert to DER for MicroPython.
openssl ec -in key.pem -out key.der -outform DER
openssl x509 -in cert.pem -out cert.der -outform DER
openssl x509 -in ca-root.pem -out ca-root.der -outform DER
}
Loading