DTLS Device Client Certificates
This guide walks through generating a Custom Device Certificate Authority (CA) and individual Device Client Certificates for your devices to achieve mutual DTLS authentication.
Prerequisites
openssl3.x (Verify usingopenssl version)A dedicated working directory for your PKI files (e.g.,
~/coap-pki/)
Constraints & Requirements
Private Key Format: Private keys must be in PKCS#8 format (
-----BEGIN PRIVATE KEY-----). OpenSSL generates PKCS#1 by default for RSA -an extra conversion step is required.Device Identity: The device client certificate's Common Name (CN) is used as the device identity identifier in akenza. Set it to the exact device identifier (e.g. serial number) you want to authenticate. It must match the deviceId used to provision a device in akenza.
Cipher Suites: Both RSA 2048 and ECDSA P-256 are supported. ECDSA produces significantly smaller certificates and is highly recommended for constrained IoT devices.
Option A - ECDSA (P-256, recommended)
1. Create the Device Certificate Authority (CA)
Never store your Root CA private key on an internet-facing device. Keep it in an offline, air-gapped environment or within a hardware security module (HSM). If the CA key is leaked, an attacker can issue valid certificates for any device identity.
mkdir -p ~/coap-pki && cd ~/coap-pki
# CA private key (PKCS#8 unencrypted)
openssl genpkey -algorithm EC -pkeyopt ec_paramgen_curve:P-256 -out ca.key
# Self-signed CA certificate (10-year validity)
openssl req -new -x509 -key ca.key -sha256 -days 3650 \
-subj "/CN=akenza CoAP CA" \
-out ca.crt2. Create a Device Client Certificate
The CN becomes the device identifier in akenza. Repeat this block for each device.
Store device private keys securely on the hardware (e.g., inside a Secure Element, TPM, or hardware-backed keystore) rather than in plain-text application files where they might be extracted during a physical or remote firmware breach.
Option B - RSA 2048
1. Create the Device Certificate Authority (CA)
Never store your Root CA private key on an internet-facing gateway, server, or device. Keep it in an offline, air-gapped environment or within a hardware security module (HSM). If the CA key is leaked, an attacker can issue valid certificates for any device identity.
2. Create a Device Client Certificate
Store device private keys securely on the hardware (e.g., inside a Secure Element, TPM, or hardware-backed keystore) rather than in plain-text application files where they might be extracted during a physical or remote firmware breach.
Test the Connection
You can verify the connection utilizing coap-client (from the libcoap package):
Success Response: Returns a payload structure like
{"message":"ok","id":"<uuid>"}.Handshake Failure: If the certificate validation or handshake fails, the client will timeout without a response, as the gateway silently drops unauthorized requests at the TLS layer.
Utility Tools
Bulk Device Client Certificate Generation
Save this automation script as gen-certs.sh to quickly issue device credentials:
Usage: ./gen-certs.sh dev-abc123 dev-def456 dev-ghi789
Inspection Commands
Last updated
Was this helpful?