MQTT integration
This section provides guidance for using the NervesKey with popular MQTT brokers.
Last updated
This section provides guidance for using the NervesKey with popular MQTT brokers.
Last updated
NervesKeys aren't only for use with NervesHub. If a service allows users to provide their own certificate authority, it should be possible to also use the NervesKey. Nearly all services use TLS or DTLS so these instructions provide guidance for using the Erlang/OTP SSL application. The following diagram shows the other compoents that are involved with establishing and authenticating MQTT connections over TLS:
In particular, the NervesKey integration with Erlang makes use of the Engine API to redirect private key operations to the cryptographic module. While nerves_key_pkcs11
provides a PKCS#11 implementation, be aware that it is minimal and only supports the operations necessary for establishing TLS connections. Programs using the NervesKey should still use the nerves_key
library for provisioning and everything else.
To use the Erlang/OTP SSL application's Engine API, you will need to do the following:
Initialize the engine to start the nerves_key_pkcs11
integration
Replace the locations where you would have suppliced a private key with an Elixir map that has a reference to the engine and other information
The nerves_key_pkcs11
library has a helper functions for both tasks.
The following example code fragment shows how to start the Tortoise MQTT client API: