Skip to main content
Device Certificates use mutual TLS (mTLS) with X.509 client certificates to authenticate every device individually. Each device carries a unique certificate signed by a Device CA that you control. When the device opens its WebSocket connection to NervesHub, both sides present and verify certificates, establishing a cryptographically authenticated channel with no shared secrets. This is the recommended authentication approach for production fleets because every device has an independent identity that can be individually revoked without affecting other devices.
The private key associated with your Device CA Certificate is never shared with or seen by NervesHub. You register only the public CA certificate. NervesHub uses it to verify device certificates at connection time — your signing key stays entirely under your control.

How It Works

When a device connects, it presents its device certificate along with the CA certificate that signed it. NervesHub checks whether the CA certificate is registered to your organization, verifies the device certificate’s signature chain, and — on the device’s first-ever connection — automatically creates a device record in your product. Subsequent connections are verified against the registered CA without any manual intervention. This flow means you can pre-provision device certificates at manufacturing time and ship devices that self-register on first boot.

Create a Device CA Certificate

Use the nh CLI to generate a new CA certificate and its associated private key:
This creates a CA certificate and key pair in your current directory. Store the private key securely — you will use it to sign individual device certificates, and it should never be placed on a device or committed to source control.
If you already operate a PKI or want to integrate with an existing CA, you can generate a compatible CA certificate using OpenSSL:
You can use this ca_cert.pem with the nh ca upload command in the next step.

Register Your CA Certificate with NervesHub

Upload your CA certificate so NervesHub can verify device certificates signed by it:
List all CA certificates registered to your organization at any time:
Each registered CA has a unique identifier you can reference when auditing or revoking certificates.
Registering and removing certificate authorities requires the admin role in the organization.

Provision Device Certificates

Generate a certificate for a specific device using the nh CLI. The device identifier (e.g., a serial number) becomes part of the certificate’s common name:
This produces a certificate and private key pair for the device. Copy these to the device’s filesystem during manufacturing or provisioning — typically to a dedicated data partition that survives firmware updates.
For high-volume provisioning, generate certificates in Elixir using the x509 library:
Point nerves_hub_link at the certificate and key files on the device filesystem. These paths should live on a partition that persists across firmware updates (e.g., /data):
Keep device certificate files on a dedicated data partition (e.g., /data/certs/) rather than the read-only firmware partition. This lets you re-provision certificates in the field without reflashing firmware, and they survive OTA updates.

First Connection and Auto-Registration

On the device’s first connection to NervesHub, the following happens automatically:
1

Device presents its certificate chain

nerves_hub_link sends the device certificate and the CA certificate during the TLS handshake.
2

NervesHub verifies the CA

NervesHub checks whether the CA certificate is registered to your organization. If it is not recognized, the connection is rejected.
3

Device is auto-registered

If the CA is recognized and the device does not yet exist in your product, NervesHub creates a new device record using the certificate’s common name as the device identifier.
4

Subsequent connections are seamless

On all future connections, NervesHub verifies the certificate against the registered CA. No additional steps are required.

Revoking a Device

To prevent a specific device from connecting, navigate to the device in the NervesCloud UI and disable or delete it. Because each device has a unique certificate, revoking one device has no effect on the rest of your fleet.

Next Steps

For the highest level of security — where the private key is physically protected and cannot be extracted even if a device is compromised — consider upgrading to hardware-backed key storage:

NervesKey Hardware Security Module

Store device private keys in an ATECC508A/608A hardware security module. The key never leaves the chip, making it ideal for large production fleets.