NervesHubLink enforces SSL peer verification on every connection. The server certificate must be valid and trusted by the device’s CA bundle. Connections to hosts with self-signed or untrusted certificates will be rejected unless you configure a custom CA certificate.
NervesCloud (Recommended)
NervesCloud is the managed NervesHub service at manage.nervescloud.com. It is the fastest way to connect devices because no infrastructure setup is required. Set your host and credentials inconfig/target.exs and NervesHubLink handles everything else:
devices.nervescloud.com endpoint is pre-trusted by the default Nerves CA bundle, so no additional certificate configuration is necessary.
Self-Hosted NervesHub
If you operate your own NervesHub instance, override thedevice_api_host, device_api_sni, and device_api_port keys to point at your server:
device_api_sni is a charlist (single-quoted), not a binary string. This value is passed directly to the underlying :ssl application for Server Name Indication during the TLS handshake.
If your server uses a private CA, provide the CA certificate so the device can verify the server’s identity:
Connection Behavior
NervesHubLink maintains a single persistent WebSocket connection to the NervesHub server. You do not need to manage reconnects in application code — the library handles them automatically:- Automatic reconnection — if the connection drops (network outage, server restart), NervesHubLink retries with exponential backoff.
- No keep-alive tuning required — Phoenix Channels send heartbeat frames; NervesHubLink responds automatically.
Disabling the Connection in Development
When runningmix test or developing on a host machine, you do not want NervesHubLink attempting to reach the NervesHub server. Disable the connection entirely with:
Runtime Configuration with a Configurator
For advanced use cases where credentials are not known at compile time — for example, when device certificates are provisioned during first boot or retrieved from a hardware security module — implement theNervesHubLink.Configurator behaviour:
config/target.exs:
build_config/1 at startup before opening the socket, so any credentials returned are used for the initial handshake and all subsequent reconnections.
