Client Usage
Overview
The rest_client.py script runs on the i.MX device and communicates with the attestation server to prove device authenticity.
Prerequisites
On the Device
nvm_daemonrunning (fromimx-secure-enclavepackage) — required for ELE firmware servicesimx-smw-appinstalled and in PATHpython3withrequestsmoduleNetwork connectivity to attestation server
Client Script Location
After installing the device-attest-scripts package:
cd /root/device_attestation/
Command Syntax
python3 rest_client.py <server_ip> <endpoint>
Parameters
server_ip: IP address of the attestation serverendpoint: Operation to perform (nonce,attest_el2go, orattest_pubkey)
Attestation Workflow
Step 0: Start NVM Daemon
Before running any attestation commands, ensure nvm_daemon is running on the device. This process manages non-volatile memory for the ELE firmware and must be active for SMW operations to succeed.
systemctl start nvm_daemon
To verify it is running:
systemctl status nvm_daemon
Note
To start it automatically on every boot, add it to /etc/rc.local or create a systemd
service unit.
Step 1: Request Nonce
Request a fresh nonce from the server:
python3 rest_client.py 192.168.1.100 nonce
Output:
[CLIENT] Nonce successfully saved to 'nonce.bin'.
What happens:
Client sends GET request to
http://192.168.1.100:8000/get_nonceServer generates cryptographic random nonce
Client saves nonce to
nonce.bin
Step 2: Perform Attestation (EL2GO Mode)
Attest using EdgeLock 2GO certificates:
python3 rest_client.py 192.168.1.100 attest_el2go
What happens:
Retrieves device UUID
Generates attestation data
Sends attestation data and UUID to server
Server retrieves certificates from EdgeLock 2GO
Server verifies attestation
Output (Success):
[CLIENT] Server response: success - Device attestation verified successfully
Output (Failure):
[CLIENT] Server response: error - Attestation verification failed
Step 3: Perform Attestation (Public Key Mode)
Attest using device public key:
python3 rest_client.py 192.168.1.100 attest_pubkey
What happens:
Generates attestation data
Exports attestation public key
Sends attestation data and public key to server
Server verifies signature using provided public key
Generated Files
After running attestation commands, the following files are created:
/root/device_attestation/
├── nonce.bin # Server-provided nonce
├── uuid.bin # Device UUID (EL2GO mode)
├── dev_attest_data.bin # Signed attestation data
└── die_attest_pub_key.bin # Device public key (pubkey mode)
Usage Examples
Complete Attestation Flow
# Step 0: Start NVM daemon (required for ELE firmware services)
systemctl start nvm_daemon
# Navigate to scripts directory
cd /root/device_attestation/
# Step 1: Get nonce
python3 rest_client.py 192.168.1.100 nonce
# Step 2: Perform attestation (choose one)
# Option A: EL2GO mode
python3 rest_client.py 192.168.1.100 attest_el2go
# Option B: Public key mode
python3 rest_client.py 192.168.1.100 attest_pubkey
Troubleshooting
SMW Error 15 / Operation Not Supported
Error: Device Attest public key reading error 15 or ERROR: Failed to retrieve die attestation public key
Cause: nvm_daemon is not running. Without it, the ELE firmware session cannot be opened and all SMW operations fail with SMW_STATUS_OPERATION_NOT_SUPPORTED (error 15). The kernel log may show:
fsl-se secure-enclave: MSG[0x10] Hdr: Cmd size mismatch.
fsl-se secure-enclave: MSG[0x30] Hdr: Cmd size mismatch.
Solution:
systemctl start nvm_daemon
# Then retry the attestation command
Connection Errors
Error: [CLIENT] Error requesting nonce: Connection refused
Causes:
Server not running
Incorrect server IP
Firewall blocking port 8000
Network connectivity issues
Solutions:
# Test connectivity
ping 192.168.1.100
# Check if server port is open
nc -zv 192.168.1.100 8000
Missing Python Modules
Error: ModuleNotFoundError: No module named 'requests'
Solution:
# Install requests module
pip3 install requests
# Or add to image recipe
IMAGE_INSTALL:append = " python3-requests"
Server Response Errors
Error: [CLIENT] Server response: error - Certificate chain verification failed
Causes:
Device not properly provisioned
Invalid certificates in EdgeLock 2GO
Certificate chain incomplete
Solutions:
Verify device provisioning status
Check EdgeLock 2GO console for device certificates
Contact NXP support for provisioning issues
Best Practices
Security
Always request fresh nonce before attestation
Don’t reuse nonce files
Secure network communication (use HTTPS in production)
Protect generated attestation files