Skip to main content
If your hardware has a Trusted Platform Module, NervesHubLink can read the device certificate from it and use its private key for the TLS handshake. NervesHub sees an ordinary device certificate. Everything in Device certificates about registering the CA and adding devices applies.

Requirements

  • nerves_hub_link 2.9.0 or later. Restoring the key file from the TPM needs 2.10.1 or later.
  • The tpm library, ~> 0.2.0, in your firmware.
  • A TPM that already holds the device’s private key and certificate. NervesHubLink reads them. It does not provision the TPM.
  • A Nerves system with the kernel module for your TPM. The configurator loads it with modprobe.
  • The CA that signed the device certificates, registered with your organization.

Enable it

1

Add the dependency

2

Configure the host

When tpm is in the project, nerves_key is not, and you have not set configurator, NervesHubLink uses NervesHubLink.Configurator.TPM. If your project has both libraries, select it explicitly:
3

Set the TPM options, if the defaults do not fit

These are the defaults. See Options.
4

Register the CA and make the devices known

Register the CA that signed the device certificates. See Register a certificate authority.Then add each device before it connects, or give the CA a just-in-time provisioning profile. The device identifier is the common name in the certificate.

What the configurator does

At startup the configurator:
  1. Runs modprobe with probe_name. It raises if modprobe fails.
  2. Checks that the TPM responds. It tries up to six times, 300 ms apart, then raises TPM Unavailable.
  3. Sets the ssl key option to the TPM private key for the file at key_path joined with key_name.
  4. If that file does not exist, reads the NV index at key_address and writes its contents to the file.
  5. Sets the ssl cert option to the certificate read from the NV index at certificate_address. The certificate must be stored there as PEM.
  6. Sets cacerts to the CA certificates NervesHubLink trusts, unless you set cacerts or cacertfile yourself. See Connecting devices.
A key or cert you set in ssl yourself is kept, and the matching step is skipped. A failure in any of these steps raises when NervesHubLink starts.

Options

Set these under the :tpm key.
string
default:"tpm_tis_spi"
The kernel module to load, for example tpm_tis_i2c.
string
default:"/data/.ssh"
The directory that holds the key file.
string
default:"nerves_hub_link_key"
The key file’s name inside key_path.
string
default:"0x1000000"
The NV index the key file is restored from when it is missing.
string
default:"0x1000001"
The NV index that holds the device certificate.

Check that it works

Boot the device and open its Settings tab in NervesHub. The Certificates card lists the certificate read from the TPM and the CA that signed it. If the key file was missing, the device logs: